(self, other: Union[None, 'Software', str])
| 60 | return self.__os |
| 61 | |
| 62 | def compare_version(self, other: Union[None, 'Software', str]) -> int: |
| 63 | # pylint: disable=too-many-branches,too-many-return-statements |
| 64 | if other is None: |
| 65 | return 1 |
| 66 | if isinstance(other, Software): |
| 67 | other = '{}{}'.format(other.version, other.patch or '') |
| 68 | else: |
| 69 | other = str(other) |
| 70 | mx = re.match(r'^([\d\.]+\d+)(.*)$', other) |
| 71 | if mx is not None: |
| 72 | oversion, opatch = mx.group(1), mx.group(2).strip() |
| 73 | else: |
| 74 | oversion, opatch = other, '' |
| 75 | if self.version < oversion: |
| 76 | return -1 |
| 77 | elif self.version > oversion: |
| 78 | return 1 |
| 79 | spatch = self.patch or '' |
| 80 | if self.product == Product.DropbearSSH: |
| 81 | if not re.match(r'^test\d.*$', opatch): |
| 82 | opatch = 'z{}'.format(opatch) |
| 83 | if not re.match(r'^test\d.*$', spatch): |
| 84 | spatch = 'z{}'.format(spatch) |
| 85 | elif self.product == Product.OpenSSH: |
| 86 | mx1 = re.match(r'^p(\d).*', opatch) |
| 87 | mx2 = re.match(r'^p(\d).*', spatch) |
| 88 | if not (bool(mx1) and bool(mx2)): |
| 89 | if mx1 is not None: |
| 90 | opatch = mx1.group(1) |
| 91 | if mx2 is not None: |
| 92 | spatch = mx2.group(1) |
| 93 | # OpenBSD version and p1 versions are considered the same. |
| 94 | if ((spatch == '') and (opatch == '1')) or ((spatch == '1') and (opatch == '')): |
| 95 | return 0 |
| 96 | if spatch < opatch: |
| 97 | return -1 |
| 98 | elif spatch > opatch: |
| 99 | return 1 |
| 100 | return 0 |
| 101 | |
| 102 | def between_versions(self, vfrom: str, vtill: str) -> bool: |
| 103 | if bool(vfrom) and self.compare_version(vfrom) < 0: |
no outgoing calls