Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyEye-FAST committed Aug 18, 2024
1 parent 097540e commit 8598fc9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
11 changes: 6 additions & 5 deletions app_init.py
Original file line number Diff line number Diff line change
@@ -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

# 是否忽略补充字符串
Expand All @@ -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'])}条字符串。")
Expand Down
5 changes: 3 additions & 2 deletions extract_font.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)}
Expand Down
5 changes: 3 additions & 2 deletions id.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"""编码语言文件键名"""

import hashlib
import json
from typing import Dict

import ujson

BASE62 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"


Expand Down Expand Up @@ -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)
21 changes: 11 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8598fc9

Please sign in to comment.