🐛 fix some bugs

This commit is contained in:
Karako 2023-05-01 21:40:50 +08:00
parent 8c1361cb43
commit 9b2fb838d8
No known key found for this signature in database
GPG Key ID: 5920831B0095D4A0
3 changed files with 10 additions and 9 deletions

View File

@ -1,3 +1,5 @@
from pathlib import Path
import ujson as json
from aiofiles import open as async_open
@ -11,7 +13,9 @@ OUT_DIR = PROJECT_ROOT.joinpath("out")
# noinspection PyShadowingBuiltins
async def parse_item_data(lang: Lang):
async def parse_item_data(
lang: Lang,
) -> tuple[Path, list[Item | Material | Food | Namecard]]:
out_path = OUT_DIR.joinpath(f"{lang}")
out_path.mkdir(exist_ok=True, parents=True)
@ -76,6 +80,7 @@ async def parse_item_data(lang: Lang):
[i.dict() for i in item_list],
ensure_ascii=False,
encode_html_chars=False,
indent=4,
),
)
breakpoint()
return out_path, item_list

View File

@ -8,7 +8,6 @@ from pydantic import Json
from yarl import URL
from utils.const import DATA_DIR
from utils.single import Singleton
from utils.typedefs import Lang
__all__ = "ResourceManager"
@ -16,7 +15,7 @@ __all__ = "ResourceManager"
ssl_context = ssl.SSLContext()
class ResourceManager(Singleton):
class ResourceManager:
_lang: Lang
_base_url: URL
@ -36,9 +35,8 @@ class ResourceManager(Singleton):
@property
def client(self) -> Client:
with self._lock:
if self._client is None or self._client.is_closed:
self._client = Client(verify=ssl_context)
if self._client is None or self._client.is_closed:
self._client = Client(verify=ssl_context)
return self._client
def refresh(self) -> None:

View File

@ -8,12 +8,10 @@ Lang = Literal[
"es",
"fr",
"id",
"it",
"jp",
"kr",
"pt",
"ru",
"th",
"tr",
"vi",
]