HonkaiStarRailWikiDataParser/func/fetch_src.py

23 lines
673 B
Python
Raw Permalink Normal View History

2023-04-25 14:40:19 +00:00
import shutil
2023-07-20 05:07:56 +00:00
from pathlib import Path
2023-04-25 14:40:19 +00:00
import aiofiles
import ujson as jsonlib
src_dir = Path("src")
data_dir = Path("data")
2023-07-05 08:42:21 +00:00
pic_lists = ["avatar_gacha", "destiny", "element"]
2023-04-25 14:40:19 +00:00
async def move_files():
for i in pic_lists:
print(f"Moving: {i}")
src_dir_ = src_dir / i
data_dir_ = data_dir / i
datas = [file.name.split(".")[0] for file in src_dir_.glob("*")]
if data_dir_.exists():
shutil.rmtree(data_dir_)
shutil.copytree(src_dir_, data_dir_)
async with aiofiles.open(data_dir_ / "info.json", "w", encoding="utf-8") as f:
await f.write(jsonlib.dumps(datas, indent=4, ensure_ascii=False))