Skip to content

Commit

Permalink
Made print statements python3 compatible in xattr.tool -- REfs #20
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Jan 12, 2014
1 parent 5abf7c4 commit 99bf0a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from setuptools import setup
from distutils.command.build import build


class cffi_build(build):
"""This is a shameful hack to ensure that cffi is present when
we specify ext_modules. We can't do this eagerly because
Expand Down
44 changes: 23 additions & 21 deletions xattr/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# IN THE SOFTWARE.
##

from __future__ import print_function

import sys
import os
import getopt
Expand All @@ -35,24 +37,24 @@

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)
Expand Down Expand Up @@ -191,15 +193,15 @@ def onError(e):
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)

Expand Down

0 comments on commit 99bf0a3

Please sign in to comment.