make_java_classpath_file.py 802 B

123456789101112131415161718192021222324252627282930
  1. import os
  2. import sys
  3. # Explicitly enable local imports
  4. # Don't forget to add imported scripts to inputs of the calling command!
  5. sys.path.append(os.path.dirname(os.path.abspath(__file__)))
  6. import process_command_files as pcf
  7. def make_cp_file(args):
  8. source = args[0]
  9. destination = args[1]
  10. with open(source) as src:
  11. lines = [line.strip() for line in src if line.strip()]
  12. with open(destination, 'w') as dst:
  13. dst.write(os.pathsep.join(lines))
  14. def make_cp_file_from_args(args):
  15. destination = args[0]
  16. with open(destination, 'w') as dst:
  17. dst.write(os.pathsep.join(args[1:]))
  18. if __name__ == '__main__':
  19. args = pcf.get_args(sys.argv[1:])
  20. if sys.argv[1] != '--from-args':
  21. make_cp_file(args)
  22. else:
  23. make_cp_file_from_args(args[1:])