From 18332c87c1d73d01ebfffb77514a680edccf520e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BC=D0=B5=D1=80=D0=B4=D0=BE=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D0=BB?= Date: Sun, 12 Feb 2023 08:19:56 +0200 Subject: [PATCH] Store raw build version in non-range case; implement comparison between build_version_raw and build_version_raw tuple --- code/Python/dbd.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/code/Python/dbd.py b/code/Python/dbd.py index 4ee13926e5..68291c191d 100755 --- a/code/Python/dbd.py +++ b/code/Python/dbd.py @@ -145,14 +145,20 @@ class build_version_raw: return "{}.{}.{}".format(self.major, self.minor, self.patch) def __lt__(self, rhs): + if type(rhs) == tuple: + rhs = rhs[0] return (self.major, self.minor, self.patch, self.build) \ < (rhs.major, rhs.minor, rhs.patch, rhs.build) def __le__(self, rhs): + if type(rhs) == tuple: + rhs = rhs[0] return (self.major, self.minor, self.patch, self.build) \ <= (rhs.major, rhs.minor, rhs.patch, rhs.build) def __eq__(self, rhs): + if type(rhs) == tuple: + return rhs[0] <= self <= rhs[-1] return (self.major, self.minor, self.patch, self.build) \ == (rhs.major, rhs.minor, rhs.patch, rhs.build) @@ -161,10 +167,14 @@ class build_version_raw: != (rhs.major, rhs.minor, rhs.patch, rhs.build) def __gt__(self, rhs): + if type(rhs) == tuple: + rhs = rhs[-1] return (self.major, self.minor, self.patch, self.build) \ > (rhs.major, rhs.minor, rhs.patch, rhs.build) def __ge__(self, rhs): + if type(rhs) == tuple: + rhs = rhs[-1] return (self.major, self.minor, self.patch, self.build) \ >= (rhs.major, rhs.minor, rhs.patch, rhs.build) @@ -174,10 +184,10 @@ class build_version_range(Grammar): def grammar_elem_init(self, sessiondata): lhs = self.elements[0] + lhs = build_version_raw(lhs.major, lhs.minor, lhs.patch, lhs.build) rhs = self.elements[1][1] if self.elements[1] else None - self.builds = (build_version_raw(lhs.major, lhs.minor, lhs.patch, lhs.build), - build_version_raw(rhs.major, rhs.minor, rhs.patch, rhs.build)) if rhs else lhs + self.builds = (lhs, build_version_raw(rhs.major, rhs.minor, rhs.patch, rhs.build)) if rhs else lhs class definition_BUILD(Grammar):