mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
cmp() doesn't exists anymore
This commit is contained in:
parent
0335bcbf4c
commit
0434bd5dc2
2 changed files with 11 additions and 10 deletions
|
@ -62,18 +62,15 @@ def domain_list(exclude_subdomains=False):
|
||||||
|
|
||||||
result_list.append(domain)
|
result_list.append(domain)
|
||||||
|
|
||||||
def cmp_domain(domain1, domain2):
|
def cmp_domain(domain):
|
||||||
# Keep the main part of the domain and the extension together
|
# Keep the main part of the domain and the extension together
|
||||||
# eg: this.is.an.example.com -> ['example.com', 'an', 'is', 'this']
|
# eg: this.is.an.example.com -> ['example.com', 'an', 'is', 'this']
|
||||||
domain1 = domain1.split('.')
|
domain = domain.split('.')
|
||||||
domain2 = domain2.split('.')
|
domain[-1] = domain[-2] + domain.pop()
|
||||||
domain1[-1] = domain1[-2] + domain1.pop()
|
domain = list(reversed(domain))
|
||||||
domain2[-1] = domain2[-2] + domain2.pop()
|
return domain
|
||||||
domain1 = list(reversed(domain1))
|
|
||||||
domain2 = list(reversed(domain2))
|
|
||||||
return cmp(domain1, domain2)
|
|
||||||
|
|
||||||
result_list = sorted(result_list, cmp_domain)
|
result_list = sorted(result_list, key=cmp_domain)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'domains': result_list,
|
'domains': result_list,
|
||||||
|
|
|
@ -70,7 +70,11 @@ def meets_version_specifier(pkg_name, specifier):
|
||||||
op, req_version = re.search(r'(<<|<=|=|>=|>>) *([\d\.]+)', specifier).groups()
|
op, req_version = re.search(r'(<<|<=|=|>=|>>) *([\d\.]+)', specifier).groups()
|
||||||
req_version = version.parse(req_version)
|
req_version = version.parse(req_version)
|
||||||
|
|
||||||
# cmp is a python builtin that returns (-1, 0, 1) depending on comparison
|
# Python2 had a builtin that returns (-1, 0, 1) depending on comparison
|
||||||
|
# c.f. https://stackoverflow.com/a/22490617
|
||||||
|
def cmp(a, b):
|
||||||
|
return (a > b) - (a < b)
|
||||||
|
|
||||||
deb_operators = {
|
deb_operators = {
|
||||||
"<<": lambda v1, v2: cmp(v1, v2) in [-1],
|
"<<": lambda v1, v2: cmp(v1, v2) in [-1],
|
||||||
"<=": lambda v1, v2: cmp(v1, v2) in [-1, 0],
|
"<=": lambda v1, v2: cmp(v1, v2) in [-1, 0],
|
||||||
|
|
Loading…
Add table
Reference in a new issue