update reading dictionaries available for download

This commit is contained in:
Helium314 2025-05-31 09:58:29 +02:00
parent 0e86978df3
commit f0d4aaa9c3

View file

@ -65,25 +65,21 @@ def update_dict_list():
for line in lines: for line in lines:
line = line.strip() line = line.strip()
if line.startswith("#"): if line.startswith("#"):
if line == "# Dictionaries": mode = 0
mode = 1 if line.startswith("# Dictionaries"):
elif line == "# Experimental dictionaries": mode = 1
mode = 2 if mode == 0 or not line.startswith("|") or line.startswith("| Language |") or line.startswith("| --- |"):
else:
mode = 0
if mode == 0 or not line.startswith("*"):
continue continue
dict_name = line.split("]")[1].split("(")[1].split(")")[0].split("/")[-1].split(".dict")[0] split = line.split("|")
dict_name = split[2].split("]")[1].split("(")[1].split(")")[0].split("/")[-1].split(".dict")[0]
(dict_type, locale) = dict_name.split("_", 1) (dict_type, locale) = dict_name.split("_", 1)
if "_" in locale: if "_" in locale:
sp = locale.split("_") sp = locale.split("_")
locale = sp[0] locale = sp[0]
for s in sp[1:]: for s in sp[1:]:
locale = locale + "_" + s.upper() locale = locale + "_" + s.upper()
if mode == 2: exp = "exp" if split[3].strip() == "yes" else ""
dicts.append(f"{dict_type},{locale},exp\n") dicts.append(f"{dict_type},{locale},{exp}\n")
else:
dicts.append(f"{dict_type},{locale},\n")
target_file = "app/src/main/assets/dictionaries_in_dict_repo.csv" target_file = "app/src/main/assets/dictionaries_in_dict_repo.csv"
with open(target_file, 'w') as f: with open(target_file, 'w') as f:
f.writelines(dicts) f.writelines(dicts)