Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
-t, \--list
: Display information about the metadata in an archive. Read the
- archive from standard output unless `--file` is specified.
+ archive from standard input unless `--file` is specified.
-x, \--extract
: Extract a metadata archive. Conceptually, perform `--start-extract`
def open_input(name):
- if name != '-':
- return open(name, 'r')
- else:
+ if not name or name == '-':
return sys.stdin
+ return open(name, 'r')
+
+
+def open_output(name):
+ if not name or name == '-':
+ return sys.stdout
+ return open(name, 'w')
optspec = """
if opt.create:
if len(remainder) < 1:
o.fatal("no paths specified for create")
- if opt.file != '-':
- output_file = open(opt.file, 'w')
- else:
- output_file = sys.stdout
+ output_file = open_output(opt.file)
metadata.save_tree(output_file,
remainder,
recurse=opt.recurse,