summaryrefslogtreecommitdiff
path: root/tools/glib-client-gen.py
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-01-03 12:33:09 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-01-03 13:56:16 +0000
commitf4634b2caf1f92f27a507207ff181d3a7927871f (patch)
tree2d1567d69145244ad97cd76cc83d550184bbc63a /tools/glib-client-gen.py
parent8058faf2407867dcda1aca35616dd23496b1b814 (diff)
downloadtelepathy-glib-f4634b2caf1f92f27a507207ff181d3a7927871f.tar.gz
Make the code generation tools work under either Python 2 or 3
They have been verified to produce identical output in _gen. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=56758 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Xavier Claessens <xavier.claessens@collabora.co.uk>
Diffstat (limited to 'tools/glib-client-gen.py')
-rw-r--r--tools/glib-client-gen.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py
index f8465a62b..e68e1a575 100644
--- a/tools/glib-client-gen.py
+++ b/tools/glib-client-gen.py
@@ -27,8 +27,8 @@ import os.path
import xml.dom.minidom
from getopt import gnu_getopt
-from libtpcodegen import file_set_contents
-from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \
+from libtpcodegen import file_set_contents, key_by_name, u
+from libglibcodegen import Signature, type_to_gtype, \
get_docstring, xml_escape, get_deprecated
@@ -74,18 +74,12 @@ class Generator(object):
self.guard = opts.get('--guard', None)
def h(self, s):
- if isinstance(s, unicode):
- s = s.encode('utf-8')
self.__header.append(s)
def b(self, s):
- if isinstance(s, unicode):
- s = s.encode('utf-8')
self.__body.append(s)
def d(self, s):
- if isinstance(s, unicode):
- s = s.encode('utf-8')
self.__docs.append(s)
def get_iface_quark(self):
@@ -1191,7 +1185,7 @@ class Generator(object):
self.b('')
nodes = self.dom.getElementsByTagName('node')
- nodes.sort(cmp_by_name)
+ nodes.sort(key=key_by_name)
for node in nodes:
self.do_interface(node)
@@ -1244,9 +1238,9 @@ class Generator(object):
self.h('#endif /* defined (%s) */' % self.guard)
self.h('')
- file_set_contents(self.basename + '.h', '\n'.join(self.__header))
- file_set_contents(self.basename + '-body.h', '\n'.join(self.__body))
- file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs))
+ file_set_contents(self.basename + '.h', u('\n').join(self.__header).encode('utf-8'))
+ file_set_contents(self.basename + '-body.h', u('\n').join(self.__body).encode('utf-8'))
+ file_set_contents(self.basename + '-gtk-doc.h', u('\n').join(self.__docs).encode('utf-8'))
def types_to_gtypes(types):
return [type_to_gtype(t)[1] for t in types]