[i18n] Local file for ISO 15924

This commit is contained in:
Al
2015-09-01 23:58:36 -04:00
parent ee4d73c65d
commit a916668f28

View File

@@ -38,6 +38,7 @@ from word_breaks import script_regex, regex_char_range
SCRIPTS_DATA_DIR = os.path.join(UNICODE_DATA_DIR, 'scripts')
LOCAL_SCRIPTS_FILE = os.path.join(SCRIPTS_DATA_DIR, 'Scripts.txt')
LOCAL_ISO_15924_FILE = os.path.join(SCRIPTS_DATA_DIR, 'iso15924.txt')
BLOCKS_DATA_DIR = os.path.join(UNICODE_DATA_DIR, 'blocks')
LOCAL_BLOCKS_FILE = os.path.join(BLOCKS_DATA_DIR, 'Blocks.txt')
@@ -268,7 +269,10 @@ SCRIPT_ALIASES_SUPPLEMENTAL = {
def get_script_codes(all_scripts):
if not os.path.exists(LOCAL_ISO_15924_FILE):
temp_dir = tempfile.gettempdir()
script_codes_filename = os.path.join(temp_dir, ISO_15924_URL.rsplit('/')[-1])
# This comes as a .zip
@@ -280,7 +284,11 @@ def get_script_codes(all_scripts):
temp_iso15924_file = u'\n'.join([line.rstrip() for line in safe_decode(zf.read(iso15924_filename)).split('\n')
if line.strip() and not line.strip().startswith('#')])
script_codes_file = StringIO(safe_encode(temp_iso15924_file))
f = open(LOCAL_ISO_15924_FILE, 'w')
f.write(safe_encode(temp_iso15924_file))
f.close()
script_codes_file = open(LOCAL_ISO_15924_FILE)
script_codes = {}
seen_scripts = set()