diff options
-rwxr-xr-x | tools/java-event-log-tags.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tools/java-event-log-tags.py b/tools/java-event-log-tags.py index f364751..6ac69bd 100755 --- a/tools/java-event-log-tags.py +++ b/tools/java-event-log-tags.py @@ -23,37 +23,43 @@ tags in the given input file. -h to display this usage message and exit. """ -import cStringIO +from __future__ import print_function + import getopt import os import os.path import re import sys +try: + from cStringIO import StringIO +except ImportError: + from io import StringIO + import event_log_tags output_file = None try: opts, args = getopt.getopt(sys.argv[1:], "ho:") -except getopt.GetoptError, err: - print str(err) - print __doc__ +except getopt.GetoptError as err: + print(str(err)) + print(__doc__) sys.exit(2) for o, a in opts: if o == "-h": - print __doc__ + print(__doc__) sys.exit(2) elif o == "-o": output_file = a else: - print >> sys.stderr, "unhandled option %s" % (o,) + print("unhandled option %s" % o, file=sys.stderr) sys.exit(1) if len(args) != 2: - print "need exactly two input files, not %d" % (len(args),) - print __doc__ + print("need exactly two input files, not %d" % len(args)) + print(__doc__) sys.exit(1) fn = args[0] @@ -85,10 +91,10 @@ if "javadoc_hide" in tagfile.options: if tagfile.errors: for fn, ln, msg in tagfile.errors: - print >> sys.stderr, "%s:%d: error: %s" % (fn, ln, msg) + print("%s:%d: error: %s" % (fn, ln, msg), file=sys.stderr) sys.exit(1) -buffer = cStringIO.StringIO() +buffer = StringIO() buffer.write("/* This file is auto-generated. DO NOT MODIFY.\n" " * Source file: %s\n" " */\n\n" % (fn,)) |