make_locale_paks.py 658 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python
  2. # usage: make_locale_paks build_dir [...]
  3. #
  4. # This script creates the .pak files under locales directory, it is used to fool
  5. # the ResourcesBundle that the locale is available.
  6. import errno
  7. import sys
  8. import os
  9. def main():
  10. target_dir = sys.argv[1]
  11. locale_dir = os.path.join(target_dir, 'locales')
  12. safe_mkdir(locale_dir)
  13. for pak in sys.argv[2:]:
  14. touch(os.path.join(locale_dir, pak + '.pak'))
  15. def touch(filename):
  16. with open(filename, 'w+'):
  17. pass
  18. def safe_mkdir(path):
  19. try:
  20. os.makedirs(path)
  21. except OSError as e:
  22. if e.errno != errno.EEXIST:
  23. raise
  24. if __name__ == '__main__':
  25. sys.exit(main())