Updated codegen to work with python3.

Most changes were just replacing usage of "has_key" with "in".
Also updated the sorting function which was simplified and
changed to a "key" function instead of "cmp" (which is no longer
supported in python3. Verified everything builds with
python 2.7 and 3.

https://bugzilla.gnome.org/show_bug.cgi?id=678066
This commit is contained in:
Simon Feltman
2012-06-13 23:20:17 -07:00
committed by Colin Walters
parent 6d5484b296
commit 03611f7c06
5 changed files with 26 additions and 40 deletions

View File

@@ -97,15 +97,8 @@ def lookup_brief_docs(annotations):
else:
return s
# I'm sure this could be a lot more elegant if I was
# more fluent in python...
def my_version_cmp(a, b):
if len(a[0]) > 0 and len(b[0]) > 0:
va = distutils.version.LooseVersion(a[0])
vb = distutils.version.LooseVersion(b[0])
ret = va.__cmp__(vb)
else:
ret = cmp(a[0], b[0])
if ret != 0:
return ret
return cmp(a[1], b[1])
def version_cmp_key(key):
# If the 'since' version is empty put a 0 in its place as this will
# allow LooseVersion to work and will always compare lower.
v = key[0] if key[0] else '0'
return (distutils.version.LooseVersion(v), key[1])