🐛 修复 metadata 目录不存在

This commit is contained in:
xtaodada 2022-10-07 13:20:15 +08:00
parent 4c702515a0
commit a1e1bb500b
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 3 additions and 1 deletions

1
.gitignore vendored
View File

@ -34,6 +34,7 @@ logs/
report/ report/
/resources/*/*/test/ /resources/*/*/test/
plugins/genshin/daily/daily.json plugins/genshin/daily/daily.json
metadata/data/
resources/assets/ resources/assets/
### DotEnv ### ### DotEnv ###

View File

@ -15,13 +15,14 @@ __all__ = [
] ]
data_dir = PROJECT_ROOT.joinpath('metadata/data/') data_dir = PROJECT_ROOT.joinpath('metadata/data/')
data_dir.mkdir(parents=True, exist_ok=True)
def _get_content(file_name: str) -> JSONType: def _get_content(file_name: str) -> JSONType:
path = data_dir.joinpath(file_name).with_suffix('.json') path = data_dir.joinpath(file_name).with_suffix('.json')
if not path.exists(): if not path.exists():
logger.error( logger.error(
"暂未找到名为 \"{file_name}.json\" 的 metadata , 请先使用 [yellow bold]/refresh_metadata[/] 命令下载", f"暂未找到名为 \"{file_name}.json\" 的 metadata , 请先使用 [yellow bold]/refresh_metadata[/] 命令下载",
extra={'markup': True} extra={'markup': True}
) )
return {} return {}