mirror of
https://github.com/PaiGramTeam/genshin-wiki.git
synced 2024-11-21 14:48:17 +00:00
🐛 fix some bugs
This commit is contained in:
parent
8c1361cb43
commit
9b2fb838d8
@ -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
|
||||
|
@ -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:
|
||||
|
@ -8,12 +8,10 @@ Lang = Literal[
|
||||
"es",
|
||||
"fr",
|
||||
"id",
|
||||
"it",
|
||||
"jp",
|
||||
"kr",
|
||||
"pt",
|
||||
"ru",
|
||||
"th",
|
||||
"tr",
|
||||
"vi",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user