<arg choice="opt">
<option>-Bbeit mask</option>
</arg>
+ <arg choice="opt">
+ <option>-O dest_dir</option>
+ </arg>
<arg choice="opt">
<option>-o output_file</option>
</arg>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>-O dest_dir</term>
+ <listitem>
+ <para>
+ Set destination directory for the output files. Default is current
+ directory.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>-o output_file</term>
<listitem>
<para>
- Useful to set the output file in case of redirected stdin:
+ Set the output file. Uses destination directory from option -O.
+ Also useful in case of redirected stdin:
<programlisting language="sh">mimedecode.py -o output_file < input_file
cat input_file | mimedecode.py -o output_file</programlisting>
</para>
def usage(code=0, errormsg=''):
version(0)
sys.stdout.write("""\
- Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header1[,h2,...]|*[,-h1,...]] [-p header1[,h2,h3,...]:param1[,p2,p3,...]] [-r header1[,h2,...]|*[,-h1,...]] [-R header1[,h2,h3,...]:param1[,p2,p3,...]] [--set-header header:value] [--set-param header:param=value] [-Bbeit mask] [-o output_file] [input_file [output_file]]
+ Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header1[,h2,...]|*[,-h1,...]] [-p header1[,h2,h3,...]:param1[,p2,p3,...]] [-r header1[,h2,...]|*[,-h1,...]] [-R header1[,h2,h3,...]:param1[,p2,p3,...]] [--set-header header:value] [--set-param header:param=value] [-Bbeit mask] [-O dest_dir] [-o output_file] [input_file [output_file]]
""" % me)
if errormsg:
sys.stderr.write(errormsg + '\n')
input_filename = None
output_filename = None
+ destination_dir = os.curdir
g = GlobalOptions
try:
options, arguments = getopt(sys.argv[1:],
- 'hVcCDPH:f:d:p:r:R:b:B:e:i:t:o:',
+ 'hVcCDPH:f:d:p:r:R:b:B:e:i:t:O:o:',
['help', 'version', 'host=', 'set-header=', 'set-param='])
except GetoptError:
usage(1)
g.ignore_mask.append(value)
elif option == '-e':
g.error_mask.append(value)
+ elif option == '-O':
+ g.destination_dir = value
elif option == '-o':
g.output_filename = value
else:
g.input_filename = '-'
infile = sys.stdin
if g.output_filename:
- outfile = open(g.output_filename, 'w')
+ outfile = open(os.path.join(g.destination_dir, g.output_filename), 'w')
else:
g.output_filename = '-'
outfile = sys.stdout
infile = open(arguments[0], 'r')
if la == 1:
if g.output_filename:
- outfile = open(g.output_filename, 'w')
+ outfile = open(os.path.join(g.destination_dir, g.output_filename), 'w')
else:
g.output_filename = '-'
outfile = sys.stdout
outfile = sys.stdout
else:
g.output_filename = arguments[1]
- outfile = open(arguments[1], 'w')
+ outfile = open(os.path.join(g.destination_dir, g.output_filename), 'w')
else:
usage(1, 'Too many arguments')