sssd/0009-sbus_codegen-Port-to-python3.patch
2015-02-14 16:20:30 +01:00

82 lines
2.4 KiB
Diff

From 4613c38c5a0fda122380074cade3aa700a6367f2 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Thu, 29 Jan 2015 10:32:23 +0100
Subject: [PATCH 9/9] sbus_codegen: Port to python3
Resolves:
https://fedorahosted.org/sssd/ticket/2017
Reviewed-by: Petr Viktorin <pviktori@redhat.com>
---
src/sbus/sbus_codegen | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/sbus/sbus_codegen b/src/sbus/sbus_codegen
index 6a96c40f5c2fdc95c9ed1238f53d0f9b9349fb98..d12b07d09923e3f5482178077ded9df11036c91c 100755
--- a/src/sbus/sbus_codegen
+++ b/src/sbus/sbus_codegen
@@ -60,14 +60,19 @@
# to generate for a given interface or method. By default the codegen will
# build up a symbol name from the DBus name.
#
+from __future__ import print_function
import optparse
import os
import re
-import StringIO
import sys
import xml.parsers.expat
+if sys.version_info[0] > 2:
+ import io as StringIO
+else:
+ import StringIO
+
# -----------------------------------------------------------------------------
# Objects
@@ -765,13 +770,13 @@ class DBusXMLParser:
self.arg_count = 0
try:
- with open(filename, "r") as f:
+ with open(filename, "rb") as f:
parser.ParseFile(f)
- except DBusXmlException, ex:
+ except DBusXmlException as ex:
ex.line = parser.CurrentLineNumber
ex.file = filename
raise
- except xml.parsers.expat.ExpatError, ex:
+ except xml.parsers.expat.ExpatError as ex:
exc = DBusXmlException(str(ex))
exc.line = ex.lineno
exc.file = filename
@@ -895,11 +900,11 @@ def parse_options():
(options, args) = parser.parse_args()
if not args:
- print >> sys.stderr, "sbus_codegen: no input file specified"
+ print("sbus_codegen: no input file specified", file=sys.stderr)
sys.exit(2)
if options.mode not in ["header", "source"]:
- print >> sys.stderr, "sbus_codegen: specify --mode=header or --mode=source"
+ print("sbus_codegen: specify --mode=header or --mode=source", file=sys.stderr)
return options, args
@@ -928,6 +933,6 @@ def main():
if __name__ == "__main__":
try:
main()
- except DBusXmlException, ex:
- print >> sys.stderr, str(ex)
+ except DBusXmlException as ex:
+ print(str(ex), file=sys.stderr)
sys.exit(1)
--
2.1.0