File: crowdin_prep.py

package info (click to toggle)
libretro-nestopia 1.52.0%2B20230102.gitcb1e24e-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,960 kB
  • sloc: cpp: 107,513; xml: 27,221; python: 1,329; ansic: 772; makefile: 634
file content (30 lines) | stat: -rw-r--r-- 1,077 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3

import core_option_translation as t

if __name__ == '__main__':
   try:
      if t.os.path.isfile(t.sys.argv[1]) or t.sys.argv[1].endswith('.h'):
         _temp = t.os.path.dirname(t.sys.argv[1])
      else:
         _temp = t.sys.argv[1]
      while _temp.endswith('/') or _temp.endswith('\\'):
         _temp = _temp[:-1]
      TARGET_DIR_PATH = _temp
   except IndexError:
      TARGET_DIR_PATH = t.os.path.dirname(t.os.path.dirname(t.os.path.realpath(__file__)))
      print("No path provided, assuming parent directory:\n" + TARGET_DIR_PATH)

   CORE_NAME = t.clean_file_name(t.sys.argv[2])
   DIR_PATH = t.os.path.dirname(t.os.path.realpath(__file__))
   H_FILE_PATH = t.os.path.join(TARGET_DIR_PATH, 'libretro_core_options.h')

   print('Getting texts from libretro_core_options.h')
   with open(H_FILE_PATH, 'r+', encoding='utf-8') as _h_file:
      _main_text = _h_file.read()
   _hash_n_str = t.get_texts(_main_text)
   _files = t.create_msg_hash(DIR_PATH, CORE_NAME, _hash_n_str)

   _source_jsons = t.h2json(_files)

   print('\nAll done!')