summaryrefslogtreecommitdiff
path: root/net-im/telepathy-logger/files/patch-tools_libtpcodegen.py
diff options
context:
space:
mode:
authorSteve Wills <swills@FreeBSD.org>2020-09-28 20:09:59 +0000
committerSteve Wills <swills@FreeBSD.org>2020-09-28 20:09:59 +0000
commitb90364b34fa501d372eb771c126025a902566f0d (patch)
treed9561c363d970eb69b46f3c793ed20972c261816 /net-im/telepathy-logger/files/patch-tools_libtpcodegen.py
parentx11/libinput: Update to 1.6.1 (diff)
telepathy ports: fix build with python 3
PR: 249549 PR: 249550 PR: 249570 PR: 249734 PR: 249735 PR: 249738 Approved by: desktop (tcberner) Obtained from: ArchLinux, see Bugzilla PRs for details
Notes
Notes: svn path=/head/; revision=550445
Diffstat (limited to 'net-im/telepathy-logger/files/patch-tools_libtpcodegen.py')
-rw-r--r--net-im/telepathy-logger/files/patch-tools_libtpcodegen.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/net-im/telepathy-logger/files/patch-tools_libtpcodegen.py b/net-im/telepathy-logger/files/patch-tools_libtpcodegen.py
new file mode 100644
index 000000000000..0c94044d29bd
--- /dev/null
+++ b/net-im/telepathy-logger/files/patch-tools_libtpcodegen.py
@@ -0,0 +1,58 @@
+--- tools/libtpcodegen.py.orig 2020-09-23 16:17:54 UTC
++++ tools/libtpcodegen.py
+@@ -21,6 +21,7 @@ please make any changes there.
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ import os
++import sys
+ from string import ascii_letters, digits
+
+
+@@ -28,6 +29,20 @@ NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpe
+
+ _ASCII_ALNUM = ascii_letters + digits
+
++if sys.version_info[0] >= 3:
++ def u(s):
++ """Return s, which must be a str literal with no non-ASCII characters.
++ This is like a more restricted form of the Python 2 u'' syntax.
++ """
++ return s.encode('ascii').decode('ascii')
++else:
++ def u(s):
++ """Return a Unicode version of s, which must be a str literal
++ (a bytestring) in which each byte is an ASCII character.
++ This is like a more restricted form of the u'' syntax.
++ """
++ return s.decode('ascii')
++
+ def file_set_contents(filename, contents):
+ try:
+ os.remove(filename)
+@@ -38,13 +53,15 @@ def file_set_contents(filename, contents):
+ except OSError:
+ pass
+
+- open(filename + '.tmp', 'w').write(contents)
++ open(filename + '.tmp', 'wb').write(contents)
+ os.rename(filename + '.tmp', filename)
+
+ def cmp_by_name(node1, node2):
+ return cmp(node1.getAttributeNode("name").nodeValue,
+ node2.getAttributeNode("name").nodeValue)
+
++def key_by_name(node):
++ return node.getAttributeNode("name").nodeValue
+
+ def escape_as_identifier(identifier):
+ """Escape the given string to be a valid D-Bus object path or service
+@@ -168,6 +185,9 @@ class _SignatureIter:
+ self.remaining = string
+
+ def next(self):
++ return self.__next__()
++
++ def __next__(self):
+ if self.remaining == '':
+ raise StopIteration
+