From a6f125c8c3f766edaeb5eed383e99cdfd62e8ab0 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 9 Oct 2021 14:36:53 +0200 Subject: [PATCH] load --- remote.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/remote.py b/remote.py index 6c70a00..c6740b9 100644 --- a/remote.py +++ b/remote.py @@ -5,21 +5,35 @@ import arguments import hypertext +ARCHIVE = '.tar.xz' +ARCHITECTURES = ['x86_64', 'i686'] CHARSET = 'u8' DISTRIBUTION = 'distrib' +SIGNATURE = '.sig' class Remote: def __init__(self, args): self.location = args[arguments.REMOTE] + self.load() - def fetch_latest_distribution(self, architecture): - url = os.path.join(self.location, DISTRIBUTION, architecture) - html = requests.get(url).content.decode(CHARSET) - links = hypertext.get_links(html) - print(links) + def load(self): + d = {} + for architecture in ARCHITECTURES: + url = os.path.join(self.location, DISTRIBUTION, architecture) + html = requests.get(url).content.decode(CHARSET) + links = sorted(hypertext.get_links(html)) + archives = [link for link in links + if link.endswith(ARCHIVE)] + signatures = [link for link in links + if link.endswith(SIGNATURE)] + archive = archives[-1] + d[architecture] = archive + self.archives = d def __str__(self): return f'''\ Location: {self.location} +Archives: +{self.archives} '''