XHS_Downloader/locale/po_to_mo.py
1570ba320c style: 代码格式化和字符串处理优化
- 优化代码缩进和换行,提高可读性
- 统一使用单引号或双引号,保持一致性
- 移除冗余的空格和括号,精简代码
2025-02-15 21:30:24 +08:00

25 lines
567 B
Python

from pathlib import Path
from subprocess import run
ROOT = Path(__file__).resolve().parent
def scan_directory():
return [
item.joinpath("LC_MESSAGES/xhs.po") for item in ROOT.iterdir() if item.is_dir()
]
def generate_map(files: list[Path]):
return [(i, i.with_suffix(".mo")) for i in files]
def generate_mo(maps: list[tuple[Path, Path]]):
for i, j in maps:
command = f'msgfmt --check -o "{j}" "{i}"'
print(run(command, shell=True, text=True))
if __name__ == "__main__":
generate_mo(generate_map(scan_directory()))