From 9cd6155f8c07dd81f347ef7546345554d1321a37 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 10 Oct 2021 15:01:24 +0200 Subject: [PATCH] location,str --- local.py | 7 +++---- remote.py | 8 +++++--- repository.py | 13 +++++++++++-- synchronization.py | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/local.py b/local.py index 36595c2..836ee7c 100644 --- a/local.py +++ b/local.py @@ -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())): diff --git a/remote.py b/remote.py index da8d24e..94703fc 100644 --- a/remote.py +++ b/remote.py @@ -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:') diff --git a/repository.py b/repository.py index 45c195b..e6a69e4 100644 --- a/repository.py +++ b/repository.py @@ -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) diff --git a/synchronization.py b/synchronization.py index 4c95d55..27956e0 100644 --- a/synchronization.py +++ b/synchronization.py @@ -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