summaryrefslogtreecommitdiff
path: root/net-im/telepathy-logger/files/patch-tools_glib-client-gen.py
blob: d47711800148867acaad9c0edde1a2b0ffda8155 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--- tools/glib-client-gen.py.orig	2020-09-23 16:17:54 UTC
+++ 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):
@@ -1187,7 +1181,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)
@@ -1240,9 +1234,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]