aboutsummaryrefslogtreecommitdiffstats
path: root/community/telepathy-logger/python3.patch
blob: 6c3cd53210d532bc55645d4ef294536d578a569e (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
This patch allows building telepathy-logger with python3.

diff -upr telepathy-logger-0.8.2.orig/tools/c-constants-gen.py telepathy-logger-0.8.2/tools/c-constants-gen.py
--- telepathy-logger-0.8.2.orig/tools/c-constants-gen.py	2015-04-28 18:48:03.000000000 +0200
+++ telepathy-logger-0.8.2/tools/c-constants-gen.py	2020-06-01 12:40:27.165796467 +0200
@@ -12,7 +12,7 @@ class Generator(object):
         self.prefix = prefix + '_'
         self.spec = get_by_path(dom, "spec")[0]
 
-	self.output_base = output_base
+        self.output_base = output_base
         self.__header = []
         self.__docs = []
 
@@ -25,10 +25,10 @@ class Generator(object):
         file_set_contents(self.output_base + '-gtk-doc.h', ''.join(self.__docs))
 
     def write(self, code):
-        self.__header.append(code.encode('utf-8'))
+        self.__header.append(code)
 
     def d(self, code):
-        self.__docs.append(code.encode('utf-8'))
+        self.__docs.append(code)
 
     # Header
     def do_header(self):
diff -upr telepathy-logger-0.8.2.orig/tools/glib-client-gen.py telepathy-logger-0.8.2/tools/glib-client-gen.py
--- telepathy-logger-0.8.2.orig/tools/glib-client-gen.py	2015-04-28 18:46:29.000000000 +0200
+++ telepathy-logger-0.8.2/tools/glib-client-gen.py	2020-06-01 12:40:27.162463141 +0200
@@ -28,7 +28,7 @@ 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 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=lambda node : node.getAttributeNode('name').nodeValue)
 
         for node in nodes:
             self.do_interface(node)
diff -upr telepathy-logger-0.8.2.orig/tools/glib-client-marshaller-gen.py telepathy-logger-0.8.2/tools/glib-client-marshaller-gen.py
--- telepathy-logger-0.8.2.orig/tools/glib-client-marshaller-gen.py	2015-04-28 18:48:03.000000000 +0200
+++ telepathy-logger-0.8.2/tools/glib-client-marshaller-gen.py	2020-06-01 12:40:27.162463141 +0200
@@ -31,23 +31,23 @@ class Generator(object):
         for signal in signals:
             self.do_signal(signal)
 
-        print 'void'
-        print '%s_register_dbus_glib_marshallers (void)' % self.prefix
-        print '{'
+        print('void')
+        print('%s_register_dbus_glib_marshallers (void)' % self.prefix)
+        print('{')
 
-        all = self.marshallers.keys()
-        all.sort()
+        all = list(self.marshallers.keys())
+        sorted(all)
         for marshaller in all:
             rhs = self.marshallers[marshaller]
 
-            print '  dbus_g_object_register_marshaller ('
-            print '      g_cclosure_marshal_generic,'
-            print '      G_TYPE_NONE,       /* return */'
+            print('  dbus_g_object_register_marshaller (')
+            print('      g_cclosure_marshal_generic,')
+            print('      G_TYPE_NONE,       /* return */')
             for type in rhs:
-                print '      G_TYPE_%s,' % type.replace('VOID', 'NONE')
-            print '      G_TYPE_INVALID);'
+                print('      G_TYPE_%s,' % type.replace('VOID', 'NONE'))
+            print('      G_TYPE_INVALID);')
 
-        print '}'
+        print('}')
 
 
 def types_to_gtypes(types):
diff -upr telepathy-logger-0.8.2.orig/tools/glib-ginterface-gen.py telepathy-logger-0.8.2/tools/glib-ginterface-gen.py
--- telepathy-logger-0.8.2.orig/tools/glib-ginterface-gen.py	2015-04-28 18:48:03.000000000 +0200
+++ telepathy-logger-0.8.2/tools/glib-ginterface-gen.py	2020-06-01 12:40:27.162463141 +0200
@@ -27,7 +27,7 @@ import os.path
 import xml.dom.minidom
 
 from libtpcodegen import file_set_contents
-from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \
+from libglibcodegen import Signature, type_to_gtype, \
         NS_TP, dbus_gutils_wincaps_to_uscore
 
 
@@ -85,18 +85,12 @@ class Generator(object):
         self.allow_havoc = allow_havoc
 
     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 do_node(self, node):
@@ -733,7 +727,7 @@ class Generator(object):
 
     def __call__(self):
         nodes = self.dom.getElementsByTagName('node')
-        nodes.sort(cmp_by_name)
+        nodes.sort(key=lambda node : node.getAttributeNode('name').nodeValue)
 
         self.h('#include <glib-object.h>')
         self.h('#include <dbus/dbus-glib.h>')
@@ -768,7 +762,7 @@ class Generator(object):
         file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs))
 
 def cmdline_error():
-    print """\
+    print("""\
 usage:
     gen-ginterface [OPTIONS] xmlfile Prefix_
 options:
@@ -788,7 +782,7 @@ options:
             void symbol (DBusGMethodInvocation *context)
         and return some sort of "not implemented" error via
             dbus_g_method_return_error (context, ...)
-"""
+""")
     sys.exit(1)
 
 
diff -upr telepathy-logger-0.8.2.orig/tools/glib-interfaces-gen.py telepathy-logger-0.8.2/tools/glib-interfaces-gen.py
--- telepathy-logger-0.8.2.orig/tools/glib-interfaces-gen.py	2015-04-28 18:48:03.000000000 +0200
+++ telepathy-logger-0.8.2/tools/glib-interfaces-gen.py	2020-06-01 12:40:27.165796467 +0200
@@ -24,13 +24,13 @@ class Generator(object):
         self.spec = get_by_path(dom, "spec")[0]
 
     def h(self, code):
-        self.decls.append(code.encode('utf-8'))
+        self.decls.append(code)
 
     def c(self, code):
-        self.impls.append(code.encode('utf-8'))
+        self.impls.append(code)
 
     def d(self, code):
-        self.docs.append(code.encode('utf-8'))
+        self.docs.append(code)
 
     def __call__(self):
         for f in self.h, self.c:
diff -upr telepathy-logger-0.8.2.orig/tools/libglibcodegen.py telepathy-logger-0.8.2/tools/libglibcodegen.py
--- telepathy-logger-0.8.2.orig/tools/libglibcodegen.py	2015-04-28 18:46:29.000000000 +0200
+++ telepathy-logger-0.8.2/tools/libglibcodegen.py	2020-06-01 12:40:27.165796467 +0200
@@ -154,7 +154,7 @@ def type_to_gtype(s):
         return ("GHashTable *", "DBUS_TYPE_G_STRING_STRING_HASHTABLE", "BOXED", False)
     elif s[:2] == 'a{':  #some arbitrary hash tables
         if s[2] not in ('y', 'b', 'n', 'q', 'i', 'u', 's', 'o', 'g'):
-            raise Exception, "can't index a hashtable off non-basic type " + s
+            raise(Exception, "can't index a hashtable off non-basic type " + s)
         first = type_to_gtype(s[2])
         second = type_to_gtype(s[3:-1])
         return ("GHashTable *", "(dbus_g_type_get_map (\"GHashTable\", " + first[1] + ", " + second[1] + "))", "BOXED", False)
@@ -169,4 +169,4 @@ def type_to_gtype(s):
         return ("GValueArray *", gtype, "BOXED", True)
 
     # we just don't know ..
-    raise Exception, "don't know the GType for " + s
+    raise(Exception, "don't know the GType for " + s)
diff -upr telepathy-logger-0.8.2.orig/tools/libtpcodegen.py telepathy-logger-0.8.2/tools/libtpcodegen.py
--- telepathy-logger-0.8.2.orig/tools/libtpcodegen.py	2015-04-28 18:46:29.000000000 +0200
+++ telepathy-logger-0.8.2/tools/libtpcodegen.py	2020-06-01 12:40:27.162463141 +0200
@@ -167,7 +167,10 @@ class _SignatureIter:
     def __init__(self, string):
         self.remaining = string
 
-    def next(self):
+    def __iter__(self):
+        self
+
+    def __next__(self):
         if self.remaining == '':
             raise StopIteration
 
diff -upr telepathy-logger-0.8.2.orig/tools/xincludator.py telepathy-logger-0.8.2/tools/xincludator.py
--- telepathy-logger-0.8.2.orig/tools/xincludator.py	2015-04-28 18:46:29.000000000 +0200
+++ telepathy-logger-0.8.2/tools/xincludator.py	2020-06-01 12:40:27.165796467 +0200
@@ -5,13 +5,11 @@ import codecs, locale
 import os
 import xml.dom.minidom
 
-stdout = codecs.getwriter('utf-8')(stdout)
-
 NS_XI = 'http://www.w3.org/2001/XInclude'
 
 def xincludate(dom, base, dropns = []):
     remove_attrs = []
-    for i in xrange(dom.documentElement.attributes.length):
+    for i in range(dom.documentElement.attributes.length):
         attr = dom.documentElement.attributes.item(i)
         if attr.prefix == 'xmlns':
             if attr.localName in dropns:
@@ -35,5 +33,5 @@ if __name__ == '__main__':
     dom = xml.dom.minidom.parse(argv[0])
     xincludate(dom, argv[0])
     xml = dom.toxml()
-    stdout.write(xml)
+    dom.writexml(stdout)
     stdout.write('\n')