This commit is contained in:
Marc Beninca 2021-10-10 13:45:02 +02:00 committed by Marc Beninca
parent 279cab318a
commit e90a4396fa
3 changed files with 30 additions and 10 deletions

View file

@ -34,14 +34,7 @@ def info(args):
def sync(args): def sync(args):
sync = synchronization.Synchronization(args) sync = synchronization.Synchronization(args)
print(sync) print(sync)
# TODO prepare temporary directory sync.run()
print('prepare…')
# TODO fetch
print('fetch…')
# TODO purge useless files
print('purge…')
# TODO clean temporary directory
print('clean…')
def main(): def main():

View file

@ -1,6 +1,7 @@
import os import os
CHARSET = 'u8' import msys
KEY = '%' KEY = '%'
SEPARATOR = f'{os.linesep}{os.linesep}' SEPARATOR = f'{os.linesep}{os.linesep}'
@ -8,7 +9,7 @@ SEPARATOR = f'{os.linesep}{os.linesep}'
class Package: class Package:
def __init__(self, package, files): def __init__(self, package, files):
for binary in [package, files]: for binary in [package, files]:
text = binary.decode(CHARSET).strip() text = binary.decode(msys.CHARSET).strip()
for item in text.split(SEPARATOR): for item in text.split(SEPARATOR):
line, *lines = item.split(os.linesep) line, *lines = item.split(os.linesep)
key = line.split(KEY)[1].lower() key = line.split(KEY)[1].lower()
@ -17,3 +18,11 @@ class Package:
else: else:
value = lines value = lines
setattr(self, key, value) setattr(self, key, value)
def __str__(self):
lines = [
f'Name: {self.name}',
f'Size: {self.csize}',
f'Hash: {self.sha256sum}',
]
return os.linesep.join(lines)

View file

@ -1,5 +1,8 @@
import os import os
import shutil
import arguments
import msys
import remote import remote
import repository import repository
@ -9,6 +12,21 @@ class Synchronization:
self.remote = remote.Remote(args) self.remote = remote.Remote(args)
self.repository = repository.Repository(args) self.repository = repository.Repository(args)
self.temporary = self.repository.get_temporary() self.temporary = self.repository.get_temporary()
self.threads = args[arguments.THREADS]
def run(self):
for architecture in self.remote.architectures:
for subsystem in msys.get_subsystems(architecture,
self.remote.subsystems):
catalog = self.remote.catalogs[architecture][subsystem]
for _, package in sorted(catalog.packages.items()):
print()
print(package)
tmp = os.path.join(self.repository.directory,
self.repository.get_temporary())
os.makedirs(tmp)
# clean temporary directory
shutil.rmtree(tmp)
def __str__(self): def __str__(self):
lines = [ lines = [