From 9b2fb838d8b7517ebdee7dcfcfd4ae242cad79bd Mon Sep 17 00:00:00 2001 From: Karako Date: Mon, 1 May 2023 21:40:50 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20some=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/item.py | 9 +++++++-- utils/manager.py | 8 +++----- utils/typedefs.py | 2 -- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/item.py b/scripts/item.py index 1bf8105..b90c877 100644 --- a/scripts/item.py +++ b/scripts/item.py @@ -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 diff --git a/utils/manager.py b/utils/manager.py index 2c60b10..faec7be 100644 --- a/utils/manager.py +++ b/utils/manager.py @@ -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: diff --git a/utils/typedefs.py b/utils/typedefs.py index 932b89e..6984f64 100644 --- a/utils/typedefs.py +++ b/utils/typedefs.py @@ -8,12 +8,10 @@ Lang = Literal[ "es", "fr", "id", - "it", "jp", "kr", "pt", "ru", "th", - "tr", "vi", ]