X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=mimedecode.py;h=78783ae6e2e7ffe930d5db226d54851e2433f7fe;hb=75fa3299ddbda6c432999a26d16fccf7bccfb34d;hp=9aab1b3e93c499fd9df152484b8481d0dd411f0e;hpb=29fcdcb768fbd333ee3aefa94336013bbcb6f298;p=mimedecode.git diff --git a/mimedecode.py b/mimedecode.py index 9aab1b3..78783ae 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -30,9 +30,6 @@ Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [ sys.exit(code) -def output(s): - gopts.outfile.write(s) - def output_headers(msg): unix_from = msg.get_unixfrom() if unix_from: @@ -350,9 +347,12 @@ if __name__ == "__main__": la = len(arguments) if la == 0: gopts.input_filename = '-' - gopts.output_filename = '-' infile = sys.stdin - outfile = sys.stdout + if gopts.output_filename: + outfile = open(gopts.output_filename, 'w') + else: + gopts.output_filename = '-' + outfile = sys.stdout elif la in (1, 2): if (arguments[0] == '-'): gopts.input_filename = '-' @@ -388,6 +388,8 @@ if __name__ == "__main__": gopts.host_name = socket.gethostname() gopts.outfile = outfile + output = outfile.write + decode_file(infile) infile.close()