Without this, files() in the arguments give an error because it's a list of mesonlib.File objects: Array as argument 1 contains a non-string. It also breaks in nested lists. Includes a test for this.pull/1382/merge
parent
16adedf6bc
commit
15b6915954
3 changed files with 37 additions and 32 deletions
@ -1,16 +1,21 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
import os |
||||
import sys |
||||
|
||||
assert(os.path.exists(sys.argv[3])) |
||||
|
||||
args = sys.argv[:-1] |
||||
|
||||
if __name__ == '__main__': |
||||
if len(sys.argv) != 3 or not sys.argv[1].startswith('--input') or \ |
||||
not sys.argv[2].startswith('--output'): |
||||
print(sys.argv[0], '--input=input_file --output=output_file') |
||||
if len(args) != 3 or not args[1].startswith('--input') or \ |
||||
not args[2].startswith('--output'): |
||||
print(args[0], '--input=input_file --output=output_file') |
||||
sys.exit(1) |
||||
with open(sys.argv[1].split('=')[1]) as f: |
||||
with open(args[1].split('=')[1]) as f: |
||||
ifile = f.read() |
||||
if ifile != 'This is a text only input file.\n': |
||||
print('Malformed input') |
||||
sys.exit(1) |
||||
with open(sys.argv[2].split('=')[1], 'w') as ofile: |
||||
with open(args[2].split('=')[1], 'w') as ofile: |
||||
ofile.write('This is a binary output file.\n') |
||||
|
Loading…
Reference in new issue