diff options
author | Mattias Andrée <maandree@operamail.com> | 2013-10-11 10:08:36 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2013-10-11 10:08:36 +0200 |
commit | ff502665a3b2ce1b4485d1fdb837c62770c20086 (patch) | |
tree | 2c6ff5e401b943974409c61585e472857424f418 /src/gpp.py | |
parent | parse command line (diff) | |
download | gpp-ff502665a3b2ce1b4485d1fdb837c62770c20086.tar.gz gpp-ff502665a3b2ce1b4485d1fdb837c62770c20086.tar.bz2 gpp-ff502665a3b2ce1b4485d1fdb837c62770c20086.tar.xz |
add iteration parameter (not used yet)
Diffstat (limited to '')
-rw-r--r-- | src/gpp.py | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -5,16 +5,18 @@ from subprocess import Popen, PIPE symbol = '@' encoding = 'utf-8' +iterations = 1 input_file = '/dev/stdin' output_file = '/dev/stdout' for i in range(1, len(sys.argv)): arg = sys.argv[i] i += 1 - if arg in ('-s', '--symbol'): symbol = sys.argv[i] - elif arg in ('-e', '--encoding'): encoding = sys.argv[i] - elif arg in ('-i', '--input'): input_file = sys.argv[i] - elif arg in ('-o', '--output'): output_file = sys.argv[i] + if arg in ('-s', '--symbol'): symbol = sys.argv[i] + elif arg in ('-e', '--encoding'): encoding = sys.argv[i] + else arg in ('-n', '--iterations') iterations = int(sys.argv[i]) + elif arg in ('-i', '--input'): input_file = sys.argv[i] + elif arg in ('-o', '--output'): output_file = sys.argv[i] elif arg in ('-f', '--file'): input_file = sys.argv[i] output_file = sys.argv[i] @@ -25,6 +27,15 @@ for i in range(1, len(sys.argv)): if input_file == '-': input_file = '/dev/stdin' if output_file == '-': output_file = '/dev/stdout' +if iterations < 1: + if input_file != output_file: + data = None + with open(input_file, 'rb') as file: + data = file.read() + with open(write_file, 'wb') as file: + file.write(data) + sys.exit(0) + data = None with open(input_file, 'rb') as file: data = file.read().decode(encoding, 'error').split('\n') |