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

@@ -304,11 +304,8 @@ class CodeGenerator:
#
# See https://bugzilla.gnome.org/show_bug.cgi?id=647577#c5
# for discussion
keys = function_pointers.keys()
if len(keys) > 0:
keys.sort(cmp=utils.my_version_cmp)
for key in keys:
self.h.write('%s'%function_pointers[key])
for key in sorted(function_pointers.keys(), key=utils.version_cmp_key):
self.h.write('%s'%function_pointers[key])
self.h.write('};\n')
self.h.write('\n')
@@ -1022,11 +1019,9 @@ class CodeGenerator:
value = '@get_%s: '%(p.name_lower)
value += 'Getter for the #%s:%s property.'%(i.camel_name, p.name_hyphen)
doc_bits[key] = value
keys = doc_bits.keys()
if len(keys) > 0:
keys.sort(cmp=utils.my_version_cmp)
for key in keys:
self.c.write(' * %s\n'%doc_bits[key])
for key in sorted(doc_bits.keys(), key=utils.version_cmp_key):
self.c.write(' * %s\n'%doc_bits[key])
self.c.write(self.docbook_gen.expand(
' *\n'
' * Virtual table for the D-Bus interface #%s.\n'