From 638706ce2f1a739a570ea3334a1cc03a5b58650f Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sun, 24 Apr 2022 22:38:40 +0200 Subject: [PATCH] Tentative prerelease support. Unfortunately requires the rewrite of most of the scripts, as it might provide multiple versions. --- loaih/versions.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/loaih/versions.py b/loaih/versions.py index 201e531..dc90f17 100644 --- a/loaih/versions.py +++ b/loaih/versions.py @@ -30,8 +30,18 @@ class BuildVersion(object): else: # String self.versions. a = self.__getbranchrel(self.query) - self.version = a['version'] - self.basedirurl = a['basedirurl'] + + if isinstance(a, list): + # If it's a list, a number of releases are provided. + self.version = [] + self.basedirurl = [] + for i in range(len(a)): + self.version[i] = self.__getlatestrel(a[i]['version']) + self.basedirurl[i] = a[i]['basedirurl'] + + else: + self.version = a['version'] + self.basedirurl = a['basedirurl'] def __getlatestrel(self, basever): """Search in downloadarchive for the latest version matching baseversion.""" @@ -62,10 +72,18 @@ class BuildVersion(object): return { 'version': version + '-' + dailyversion, 'basedirurl': basedirurl } if branch == 'prerelease': - version = etree.HTML(urllib.request.urlopen(BuildVersion.PRERELEASE).read()).xpath('//td/a')[1].text.split('_')[1] + # Also here, we'll rely on DownloadPage. Whenever a prerelease version is cited in the page. + version = etree.HTML(urllib.request.urlopen(BuildVersion.DOWNLOADPAGE).read()).xpath('//p[@class="lead_libre"][last()]/following-sibling::ul[last()]/li/a/text()') + retval = [] basedirurl = { u'x86': '-', u'x86_64': BuildVersion.PRERELEASE } + + if len(version) == 0: + return retval - return { 'version': version, 'basedirurl': basedirurl } + for v in version: + retval.append({ 'version': v, 'basedirurl': basedirurl }) + + return retval # Stable releases. # Old approach - Doesn't really work because RelEng can screw order.