repository.load
This commit is contained in:
parent
045b469e4a
commit
e52047d1fd
1 changed files with 22 additions and 1 deletions
|
@ -2,6 +2,8 @@ import arguments
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import remote
|
||||||
|
|
||||||
|
|
||||||
class Repository:
|
class Repository:
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
|
@ -10,11 +12,30 @@ class Repository:
|
||||||
self.tmp = os.path.join(self.temporary,
|
self.tmp = os.path.join(self.temporary,
|
||||||
datetime.datetime.now()
|
datetime.datetime.now()
|
||||||
.strftime('%Y%m%d%H%M%S'))
|
.strftime('%Y%m%d%H%M%S'))
|
||||||
|
self.load()
|
||||||
|
|
||||||
|
def load(self):
|
||||||
|
distribution = os.path.join(
|
||||||
|
self.directory, remote.DISTRIBUTION)
|
||||||
|
d = {}
|
||||||
|
_, architectures, _ = next(os.walk(distribution))
|
||||||
|
for architecture in [a for a in architectures
|
||||||
|
if a in remote.ARCHITECTURES]:
|
||||||
|
directory = os.path.join(distribution, architecture)
|
||||||
|
_, _, files = next(os.walk(directory))
|
||||||
|
archives = sorted([file for file in files
|
||||||
|
if file.endswith(remote.ARCHIVE)])
|
||||||
|
archive = archives[-1]
|
||||||
|
d[architecture] = archive
|
||||||
|
self.archives = d
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
lines = [
|
lines = [
|
||||||
f'Directory: {self.directory}',
|
f'Directory: {self.directory}',
|
||||||
f' → {os.path.realpath(self.directory)}',
|
f' → {os.path.realpath(self.directory)}',
|
||||||
f'Temporary: {self.tmp}',
|
f'Archives:',
|
||||||
]
|
]
|
||||||
|
for architecture, archive in reversed(sorted(self.archives.items())):
|
||||||
|
lines.append(f'{architecture} → {archive}')
|
||||||
|
lines.append(f'Temporary: {self.tmp}')
|
||||||
return os.linesep.join(lines)
|
return os.linesep.join(lines)
|
||||||
|
|
Loading…
Reference in a new issue