make_manifest_from_bf.py 773 B

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