link_jsrc.py 711 B

123456789101112131415161718192021222324252627
  1. import argparse
  2. import tarfile
  3. def parse_args():
  4. parser = argparse.ArgumentParser()
  5. parser.add_argument('--input', nargs='*')
  6. parser.add_argument('--output', required=True)
  7. return parser.parse_args()
  8. def main():
  9. args = parse_args()
  10. with tarfile.open(args.output, 'w') as dest:
  11. for jsrc in [j for j in args.input if j.endswith('.jsrc')]:
  12. with tarfile.open(jsrc, 'r') as src:
  13. for item in [m for m in src.getmembers() if m.name != '']:
  14. if item.isdir():
  15. dest.addfile(item)
  16. else:
  17. dest.addfile(item, src.extractfile(item))
  18. if __name__ == '__main__':
  19. main()