diff --git a/app_init.py b/app_init.py index 417243c..ead703d 100644 --- a/app_init.py +++ b/app_init.py @@ -1,9 +1,10 @@ # -*- encoding: utf-8 -*- """初始化文件""" -import json from typing import Dict +import ujson + from app_base import LANG_DIR, LANG_DIR_VALID, ID_MAP_PATH, RATING_PATH, language_list # 是否忽略补充字符串 @@ -13,21 +14,21 @@ data: Dict[str, Dict[str, str]] = {} for lang_name in language_list: with open(LANG_DIR_VALID / f"{lang_name}.json", "r", encoding="utf-8") as f: - data[lang_name] = json.load(f) + data[lang_name] = ujson.load(f) # 读取ID映射 with open(ID_MAP_PATH, "r", encoding="utf-8") as f: - id_map = json.load(f) + id_map = ujson.load(f) # 读取题目评级 with open(RATING_PATH, "r", encoding="utf-8") as f: - rating = json.load(f) + rating = ujson.load(f) # 读取补充字符串 if not IGNORE_SUPPLEMENTS: language_list.remove("en_us") with open(LANG_DIR / "supplements.json", "r", encoding="utf-8") as f: - supplements: Dict[str, Dict[str, str]] = json.load(f) + supplements: Dict[str, Dict[str, str]] = ujson.load(f) for lang in language_list: data[lang].update(supplements[lang]) print(f"已补充{len(supplements['zh_cn'])}条字符串。") diff --git a/extract_font.py b/extract_font.py index ed1117b..3c4f092 100644 --- a/extract_font.py +++ b/extract_font.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- """字体子集生成器""" -import json from typing import Dict + +import ujson from fontTools import subset from app_base import P, LANG_DIR_VALID @@ -13,7 +14,7 @@ def main() -> None: # 读取语言文件 with open(LANG_DIR_VALID / "lzh.json", "r", encoding="utf-8") as file: - data: Dict[str, str] = json.load(file) + data: Dict[str, str] = ujson.load(file) # 提取字符串中包含的所有字符 all_char = {char for value in data.values() for char in str(value)} diff --git a/id.py b/id.py index 9ec2072..12a68fd 100644 --- a/id.py +++ b/id.py @@ -2,9 +2,10 @@ """编码语言文件键名""" import hashlib -import json from typing import Dict +import ujson + BASE62 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" @@ -43,4 +44,4 @@ def sha256_to_base62(input_string: str, length: int = 3) -> str: print(f"编码: {code} -> 键: {key}") with open(ID_MAP_PATH, "w", encoding="utf-8") as f: - json.dump(code_to_key_map, f, ensure_ascii=False, indent=4) + ujson.dump(code_to_key_map, f, ensure_ascii=False, indent=4) diff --git a/requirements.txt b/requirements.txt index 527aeb5..5726d87 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,11 @@ -Babel==2.14.0 -beautifulsoup4==4.12.3 -Flask==3.0.3 -flask_babel==4.0.0 -flask_wtf==1.2.1 -fonttools==4.50.0 -geoip2==4.8.0 -python-dotenv==1.0.1 -Requests==2.31.0 -WTForms==3.1.2 +Babel>=2.16.0 +Flask>=3.0.3 +flask_babel>=4.0.0 +flask_wtf>=1.2.1 +fonttools>=4.53.1 +geoip2>=4.8.0 +python-dotenv>=1.0.1 +Requests>=2.32.3 +rich>=13.7.1 +ujson>=5.10.0 +WTForms>=3.1.2