From db4c957e1d4586f6cdef829e9d2987b6cd6b9560 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Thu, 12 May 2022 22:57:11 +0200 Subject: [PATCH] Fix per numero di build vuoto. --- loaih/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index d15ccc8..f424f60 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -87,10 +87,13 @@ class Base(object): def fullversion(version): """Get latest full version from Archive based on partial version.""" versionlist = etree.HTML(urllib.request.urlopen(Definitions.ARCHIVE).read()).xpath(f"//td/a[starts-with(text(), '{version}')]/text()") - cleanlist = sorted([ x.strip('/') for x in versionlist ]) + if versionlist: + cleanlist = sorted([ x.strip('/') for x in versionlist ]) - # Sorting, then returning the last version - return cleanlist[-1] + # Sorting, then returning the last version + return cleanlist[-1] + + return None @staticmethod def urlfromqueryandver(query, version): @@ -139,6 +142,11 @@ class Base(object): else: # Named query a = Base.namedver(query) + + if not a: + # a is empty + return retval + if isinstance(a, list) and len(a) > 1: retval.extend([ RemoteBuild(query, version) for version in a ]) else: @@ -168,6 +176,10 @@ class RemoteBuild(object): a = Base.namedver(self.query) if isinstance(a, list): + # if the number of versions is zero, return and exit + if not a: + return None + if len(a) == 1: # version is a single one. self.version = a[0]