| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import os |
| 4 |
import sys |
| 5 |
|
| 6 |
assert os.path.exists(sys.argv[3]) |
| 7 |
|
| 8 |
args = sys.argv[:-1] |
| 9 |
|
| 10 |
if __name__ == '__main__': |
| 11 |
assert os.environ['MY_COMPILER_ENV'] == 'value' |
| 12 |
if len(args) != 3 or not args[1].startswith('--input') or \ |
| 13 |
not args[2].startswith('--output'): |
| 14 |
print(args[0], '--input=input_file --output=output_file') |
| 15 |
sys.exit(1) |
| 16 |
with open(args[1].split('=', 1)[1]) as f: |
| 17 |
ifile = f.read() |
| 18 |
if ifile != 'This is a text only input file.\n': |
| 19 |
print('Malformed input') |
| 20 |
sys.exit(1) |
| 21 |
with open(args[2].split('=', 1)[1], 'w', encoding='utf-8') as ofile: |
| 22 |
ofile.write('This is a binary output file.\n') |