mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
fix bug on pkgver compare
This commit is contained in:
parent
c0031235a6
commit
9187984b6b
1 changed files with 4 additions and 10 deletions
|
@ -2,24 +2,18 @@ import os
|
|||
from collections import namedtuple
|
||||
import subprocess
|
||||
import re
|
||||
from typing import Tuple, List, Dict
|
||||
from typing import List, Dict
|
||||
|
||||
from pkg_resources import parse_version as _parse_version
|
||||
from packaging.version import Version # type: ignore
|
||||
|
||||
def parse_arch_version(v: str) -> Tuple[int, Version]:
|
||||
if ':' in v:
|
||||
epoch = int(v.split(':', 1)[0])
|
||||
else:
|
||||
epoch = 0
|
||||
return epoch, _parse_version(v)
|
||||
|
||||
class PkgNameInfo(namedtuple('PkgNameInfo', 'name, version, release, arch')):
|
||||
def __lt__(self, other) -> bool:
|
||||
if self.name != other.name or self.arch != other.arch:
|
||||
return NotImplemented
|
||||
if self.version != other.version:
|
||||
return parse_arch_version(self.version) < parse_arch_version(other.version)
|
||||
p = subprocess.Popen(["vercmp", self.version, other.version], stdout=subprocess.PIPE)
|
||||
output = p.stdout.read()
|
||||
return int(output) < 0
|
||||
return float(self.release) < float(other.release)
|
||||
|
||||
def __gt__(self, other) -> bool:
|
||||
|
|
Loading…
Add table
Reference in a new issue