Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

detab

  • Loading branch information...
commit c45b708511e5d89dd8bde8f6d47d3ca325d83cd7 1 parent d05855c
@etrepum etrepum authored
Showing with 70 additions and 70 deletions.
  1. +70 −70 Lib/xattr/tool.py
View
140 Lib/xattr/tool.py
@@ -74,89 +74,89 @@ def main():
elif opt == "-l":
long_format = True
elif opt == "-p":
- read = True
+ read = True
elif opt == "-w":
- write = True
+ write = True
elif opt == "-d":
- delete = True
+ delete = True
if write or delete:
- if long_format:
- usage("-l not allowed with -w or -p")
+ if long_format:
+ usage("-l not allowed with -w or -p")
if read or write or delete:
- if not args:
- usage("No attr_name")
- attr_name = args.pop(0)
+ if not args:
+ usage("No attr_name")
+ attr_name = args.pop(0)
if write:
- if not args:
- usage("No attr_value")
- attr_value = args.pop(0)
+ if not args:
+ usage("No attr_value")
+ attr_value = args.pop(0)
if len(args) > 1:
- multiple_files = True
+ multiple_files = True
else:
- multiple_files = False
+ multiple_files = False
for filename in args:
- def onError(e):
- if not os.path.exists(filename):
- sys.stderr.write("No such file: %s\n" % (filename,))
- else:
- sys.stderr.write(str(e) + "\n")
- status = 1
-
- try:
- attrs = xattr.xattr(filename)
- except (IOError, OSError), e:
- onError(e)
- continue
-
- if write:
- try:
- attrs[attr_name] = attr_value
- except (IOError, OSError), e:
- onError(e)
- continue
-
- elif delete:
- try:
- del attrs[attr_name]
- except (IOError, OSError), e:
- onError(e)
- continue
- except KeyError:
- onError("No such xattr: %s" % (attr_name,))
- continue
-
- else:
- try:
- if read:
- attr_names = (attr_name,)
- else:
- attr_names = attrs.keys()
- except (IOError, OSError), e:
- onError(e)
- continue
-
- if multiple_files:
- file_prefix = "%s: " % (filename,)
- else:
- file_prefix = ""
-
- for attr_name in attr_names:
- try:
- if long_format:
- print "".join((file_prefix, "%s: " % (attr_name,), attrs[attr_name]))
- else:
- if read:
- print "".join((file_prefix, attrs[attr_name]))
- else:
- print "".join((file_prefix, attr_name))
- except KeyError:
- onError("%sNo such xattr: %s" % (file_prefix, attr_name))
- continue
+ def onError(e):
+ if not os.path.exists(filename):
+ sys.stderr.write("No such file: %s\n" % (filename,))
+ else:
+ sys.stderr.write(str(e) + "\n")
+ status = 1
+
+ try:
+ attrs = xattr.xattr(filename)
+ except (IOError, OSError), e:
+ onError(e)
+ continue
+
+ if write:
+ try:
+ attrs[attr_name] = attr_value
+ except (IOError, OSError), e:
+ onError(e)
+ continue
+
+ elif delete:
+ try:
+ del attrs[attr_name]
+ except (IOError, OSError), e:
+ onError(e)
+ continue
+ except KeyError:
+ onError("No such xattr: %s" % (attr_name,))
+ continue
+
+ else:
+ try:
+ if read:
+ attr_names = (attr_name,)
+ else:
+ attr_names = attrs.keys()
+ except (IOError, OSError), e:
+ onError(e)
+ continue
+
+ if multiple_files:
+ file_prefix = "%s: " % (filename,)
+ else:
+ file_prefix = ""
+
+ for attr_name in attr_names:
+ try:
+ if long_format:
+ print "".join((file_prefix, "%s: " % (attr_name,), attrs[attr_name]))
+ else:
+ if read:
+ print "".join((file_prefix, attrs[attr_name]))
+ else:
+ print "".join((file_prefix, attr_name))
+ except KeyError:
+ onError("%sNo such xattr: %s" % (file_prefix, attr_name))
+ continue
sys.exit(status)
Please sign in to comment.
Something went wrong with that request. Please try again.