diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-01-11 23:28:14 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-01-11 23:28:14 -0800 |
commit | 99bf0a398030579f91dd212df9c25f0297f59e4f (patch) | |
tree | b312dd03df30cae821cf8230341cbaba1281e46f /xattr | |
parent | 5abf7c4890e8038a87d7f4a45b82b8aa7c6f63b6 (diff) | |
download | xattr-99bf0a398030579f91dd212df9c25f0297f59e4f.tar.gz |
Made print statements python3 compatible in xattr.tool -- REfs #20
Diffstat (limited to 'xattr')
-rwxr-xr-x | xattr/tool.py | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/xattr/tool.py b/xattr/tool.py index 41ea7e1..a310506 100755 --- a/xattr/tool.py +++ b/xattr/tool.py @@ -25,6 +25,8 @@ # IN THE SOFTWARE. ## +from __future__ import print_function + import sys import os import getopt @@ -35,24 +37,24 @@ import xattr def usage(e=None): if e: - print e - print "" + print(e) + print("") name = os.path.basename(sys.argv[0]) - print "usage: %s [-lz] file [file ...]" % (name,) - print " %s -p [-lz] attr_name file [file ...]" % (name,) - print " %s -w [-z] attr_name attr_value file [file ...]" % (name,) - print " %s -d attr_name file [file ...]" % (name,) - print "" - print "The first form lists the names of all xattrs on the given file(s)." - print "The second form (-p) prints the value of the xattr attr_name." - print "The third form (-w) sets the value of the xattr attr_name to attr_value." - print "The fourth form (-d) deletes the xattr attr_name." - print "" - print "options:" - print " -h: print this help" - print " -l: print long format (attr_name: attr_value)" - print " -z: compress or decompress (if compressed) attribute value in zip format" + print("usage: %s [-lz] file [file ...]" % (name,)) + print(" %s -p [-lz] attr_name file [file ...]" % (name,)) + print(" %s -w [-z] attr_name attr_value file [file ...]" % (name,)) + print(" %s -d attr_name file [file ...]" % (name,)) + print("") + print("The first form lists the names of all xattrs on the given file(s).") + print("The second form (-p) prints the value of the xattr attr_name.") + print("The third form (-w) sets the value of the xattr attr_name to attr_value.") + print("The fourth form (-d) deletes the xattr attr_name.") + print("") + print("options:") + print(" -h: print this help") + print(" -l: print long format (attr_name: attr_value)") + print(" -z: compress or decompress (if compressed) attribute value in zip format") if e: sys.exit(64) @@ -191,15 +193,15 @@ def main(): try: if attr_value.find('\0') >= 0: raise NullsInString - print "".join((file_prefix, "%s: " % (attr_name,), attr_value)) + print("".join((file_prefix, "%s: " % (attr_name,), attr_value))) except (UnicodeDecodeError, NullsInString): - print "".join((file_prefix, "%s:" % (attr_name,))) - print _dump(attr_value) + print("".join((file_prefix, "%s:" % (attr_name,)))) + print(_dump(attr_value)) else: if read: - print "".join((file_prefix, attr_value)) + print("".join((file_prefix, attr_value))) else: - print "".join((file_prefix, attr_name)) + print("".join((file_prefix, attr_name))) sys.exit(status) |