From d03d9ebcbfe5db44e338627ee247f0fb03bab5ff Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 10 Oct 2021 04:43:33 +0200 Subject: [PATCH] get_subsystems --- msys.py | 22 ++++++++++++++++++---- remote.py | 16 +++++++--------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/msys.py b/msys.py index b0a5db0..eac4de7 100644 --- a/msys.py +++ b/msys.py @@ -4,14 +4,28 @@ ARCHITECTURES_BITS = { 'x86_64': 64, 'i686': 32, } -ARCHITECTURES_SUBSYSTEMS = { - 'x86_64': ['msys', 'clang64', 'mingw64', 'ucrt64'], - 'i686': ['msys', 'clang32', 'mingw32'], -} CATALOG = '.files' CHARSET = 'u8' CRT = 'mingw' DISTRIBUTION = 'distrib' SIGNATURE = '.sig' SUBSYSTEM = 'msys' + +ARCHITECTURES_SUBSYSTEMS = { + 'x86_64': [SUBSYSTEM, 'clang64', 'mingw64', 'ucrt64'], + 'i686': [SUBSYSTEM, 'clang32', 'mingw32'], +} SUBSYSTEMS = [SUBSYSTEM, 'clang', 'mingw', 'ucrt'] + + +def get_subsystems(architecture, families): + list = [] + bits = ARCHITECTURES_BITS[architecture] + for family in families: + if family == SUBSYSTEM: + subsystem = family + else: + subsystem = f'{family}{bits}' + if subsystem in ARCHITECTURES_SUBSYSTEMS[architecture]: + list.append(subsystem) + return list diff --git a/remote.py b/remote.py index 0adb8de..11d04e4 100644 --- a/remote.py +++ b/remote.py @@ -18,24 +18,22 @@ class Remote: a = {} c = {} for architecture in self.architectures: + subsystems = msys.get_subsystems(architecture, self.subsystems) location = os.path.join(self.location, msys.DISTRIBUTION, architecture) a[architecture] = hypertext.HyperText(location).archive # c[architecture] = {} - for ss in self.subsystems: + for subsystem in subsystems: location = self.location - if ss == msys.SUBSYSTEMS[0]: - subsystem = ss + if subsystem == msys.SUBSYSTEM: location = os.path.join(location, subsystem, architecture) else: - subsystem = f'{ss}{msys.ARCHITECTURES_BITS[architecture]}' location = os.path.join(location, msys.CRT, subsystem) - if subsystem in msys.ARCHITECTURES_SUBSYSTEMS[architecture]: - location = os.path.join(location, - f'{subsystem}{msys.CATALOG}') - binary = requests.get(location).content - c[architecture][subsystem] = catalog.Catalog(binary) + location = os.path.join(location, + f'{subsystem}{msys.CATALOG}') + binary = requests.get(location).content + c[architecture][subsystem] = catalog.Catalog(binary) self.archives = a self.catalogs = c