mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2026-01-09 20:07:02 +08:00
add exception handling
This commit is contained in:
parent
f29921d85d
commit
ff89cda9b2
@ -37,16 +37,21 @@ def scan_i18n_strings():
|
||||
strings = []
|
||||
print(" Scanning Files and Extracting i18n Strings ".center(TITLE_LEN, "="))
|
||||
for filename in glob.iglob("**/*.py", recursive=True):
|
||||
try:
|
||||
with open(filename, "r", encoding="utf-8") as f:
|
||||
code = f.read()
|
||||
if "I18nAuto" in code:
|
||||
tree = ast.parse(code)
|
||||
i18n_strings = extract_i18n_strings(tree)
|
||||
print(f"{filename.ljust(30)}: {len(i18n_strings)}")
|
||||
print(f"{filename.ljust(KEY_LEN*3//2)}: {len(i18n_strings)}")
|
||||
if SHOW_KEYS:
|
||||
print("\n".join([s for s in i18n_strings]))
|
||||
strings.extend(i18n_strings)
|
||||
except Exception as e:
|
||||
print(f"\033[31m[Failed] Error occur at {filename}: {e}\033[0m")
|
||||
|
||||
code_keys = set(strings)
|
||||
print(f"{'Total Unique'.ljust(30)}: {len(code_keys)}")
|
||||
print(f"{'Total Unique'.ljust(KEY_LEN*3//2)}: {len(code_keys)}")
|
||||
return code_keys
|
||||
|
||||
def update_i18n_json(json_file, standard_keys):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user