location,str

This commit is contained in:
Marc Beninca 2021-10-10 15:01:24 +02:00 committed by Marc Beninca
parent 3707f42b77
commit 9cd6155f8c
4 changed files with 21 additions and 11 deletions

View file

@ -8,13 +8,13 @@ import repository
class Local(repository.Repository):
def __init__(self, args):
self.directory = args[arguments.DIRECTORY]
super().__init__(args[arguments.DIRECTORY])
self.temporary = args[arguments.TEMPORARY]
self.load()
def load(self):
distribution = os.path.join(
self.directory, msys.DISTRIBUTION)
self.location, msys.DISTRIBUTION)
d = {}
_, architectures, _ = next(os.walk(distribution))
for architecture in [a for a in architectures
@ -34,8 +34,7 @@ class Local(repository.Repository):
def __str__(self):
lines = [
f'Directory: {self.directory}',
f'{os.path.realpath(self.directory)}',
super().__str__(),
'Archives:',
]
for architecture, archive in reversed(sorted(self.archives.items())):

View file

@ -10,7 +10,7 @@ import repository
class Remote(repository.Repository):
def __init__(self, args):
self.location = args[arguments.REMOTE]
super().__init__(args[arguments.REMOTE])
self.architectures = args[arguments.ARCHITECTURES]
self.subsystems = args[arguments.SUBSYSTEMS]
self.load()
@ -36,8 +36,10 @@ class Remote(repository.Repository):
self.catalogs = c
def __str__(self):
lines = [f'Location: {self.location}',
'Archives:']
lines = [
super().__str__(),
'Archives:',
]
for architecture, archive in reversed(sorted(self.archives.items())):
lines.append(f'{architecture}{archive}')
lines.append('Subsystems:')

View file

@ -1,3 +1,12 @@
import os
class Repository:
def __init__(self):
pass
def __init__(self, location):
self.location = location
def __str__(self):
lines = [
f'Location: {self.location}',
]
return os.linesep.join(lines)

View file

@ -26,12 +26,12 @@ class Synchronization:
os.path.join(self.remote.location, path),
package.name,
package.csize,
os.path.join(self.repository.directory, path),
os.path.join(self.repository.location, path),
package.sha256sum,
)
print()
print(f)
tmp = os.path.join(self.repository.directory,
tmp = os.path.join(self.repository.location,
self.repository.get_temporary())
os.makedirs(tmp)
# clean temporary directory