make_manifest_from_bf.py 763 B

123456789101112131415161718192021222324252627
  1. import sys
  2. import zipfile
  3. import os
  4. def prepare_path(path):
  5. return ('file:/' + path.lstrip('/')) if os.path.isabs(path) else path
  6. def main(args):
  7. bf, mf = args[0], args[1]
  8. if not os.path.exists(os.path.dirname(mf)):
  9. os.makedirs(os.path.dirname(mf))
  10. with open(bf) as f:
  11. class_path = f.read().strip()
  12. class_path = ' '.join(map(prepare_path, class_path.split('\n')))
  13. with zipfile.ZipFile(mf, 'w') as zf:
  14. lines = []
  15. while class_path:
  16. lines.append(class_path[:60])
  17. class_path = class_path[60:]
  18. if lines:
  19. zf.writestr('META-INF/MANIFEST.MF', 'Manifest-Version: 1.0\nClass-Path: \n ' + '\n '.join(lines) + ' \n\n')
  20. if __name__ == '__main__':
  21. main(sys.argv[1:])