Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix rc build comparison via natural cmp helper.

  • Loading branch information...
commit e9e436fe222b8afd939ccc46681f970471e4f2f6 1 parent ee1919e
@kxepal authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 semver.py
View
8 semver.py
@@ -26,9 +26,15 @@ def parse(version):
def compare(ver1, ver2):
+ def nat_cmp(a, b):
+ a, b = a and str(a) or '', b and str(b) or ''
+ convert = lambda text: int(text) if text.isdigit() else text.lower()
+ alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
+ return cmp(alphanum_key(a), alphanum_key(b))
+
def compare_by_keys(d1, d2, keys):
for key in keys:
- v = cmp(d1.get(key), d2.get(key))
+ v = nat_cmp(d1.get(key), d2.get(key))
if v != 0:
return v
return 0
Please sign in to comment.
Something went wrong with that request. Please try again.