process_command_files.py 791 B

1234567891011121314151617181920212223242526272829303132333435
  1. def is_cmdfile_arg(arg):
  2. return arg.startswith('@')
  3. def cmdfile_path(arg):
  4. return arg[1:]
  5. def read_from_command_file(arg):
  6. with open(arg) as afile:
  7. return afile.read().splitlines()
  8. def skip_markers(args):
  9. res = []
  10. for arg in args:
  11. if arg == '--ya-start-command-file' or arg == '--ya-end-command-file':
  12. continue
  13. res.append(arg)
  14. return res
  15. def iter_args(args):
  16. for arg in args:
  17. if not is_cmdfile_arg(arg):
  18. if arg == '--ya-start-command-file' or arg == '--ya-end-command-file':
  19. continue
  20. yield arg
  21. else:
  22. for cmdfile_arg in read_from_command_file(cmdfile_path(arg)):
  23. yield cmdfile_arg
  24. def get_args(args):
  25. return list(iter_args(args))