my_compiler2.py 431 B

12345678910111213141516
  1. #!/usr/bin/env python
  2. import sys
  3. if __name__ == '__main__':
  4. if len(sys.argv) != 3:
  5. print(sys.argv[0], 'input_file output_file')
  6. sys.exit(1)
  7. with open(sys.argv[1]) as f:
  8. ifile = f.read()
  9. if ifile != 'This is a binary output file.\n':
  10. print('Malformed input')
  11. sys.exit(1)
  12. with open(sys.argv[2], 'w') as ofile:
  13. ofile.write('This is a different binary output file.\n')