mirror of
https://github.com/PaiGramTeam/genshin-wiki.git
synced 2024-11-21 22:58:02 +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
|
import ujson as json
|
||||||
from aiofiles import open as async_open
|
from aiofiles import open as async_open
|
||||||
|
|
||||||
@ -11,7 +13,9 @@ OUT_DIR = PROJECT_ROOT.joinpath("out")
|
|||||||
|
|
||||||
|
|
||||||
# noinspection PyShadowingBuiltins
|
# 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 = OUT_DIR.joinpath(f"{lang}")
|
||||||
out_path.mkdir(exist_ok=True, parents=True)
|
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],
|
[i.dict() for i in item_list],
|
||||||
ensure_ascii=False,
|
ensure_ascii=False,
|
||||||
encode_html_chars=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 yarl import URL
|
||||||
|
|
||||||
from utils.const import DATA_DIR
|
from utils.const import DATA_DIR
|
||||||
from utils.single import Singleton
|
|
||||||
from utils.typedefs import Lang
|
from utils.typedefs import Lang
|
||||||
|
|
||||||
__all__ = "ResourceManager"
|
__all__ = "ResourceManager"
|
||||||
@ -16,7 +15,7 @@ __all__ = "ResourceManager"
|
|||||||
ssl_context = ssl.SSLContext()
|
ssl_context = ssl.SSLContext()
|
||||||
|
|
||||||
|
|
||||||
class ResourceManager(Singleton):
|
class ResourceManager:
|
||||||
_lang: Lang
|
_lang: Lang
|
||||||
_base_url: URL
|
_base_url: URL
|
||||||
|
|
||||||
@ -36,9 +35,8 @@ class ResourceManager(Singleton):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def client(self) -> Client:
|
def client(self) -> Client:
|
||||||
with self._lock:
|
if self._client is None or self._client.is_closed:
|
||||||
if self._client is None or self._client.is_closed:
|
self._client = Client(verify=ssl_context)
|
||||||
self._client = Client(verify=ssl_context)
|
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
def refresh(self) -> None:
|
def refresh(self) -> None:
|
||||||
|
@ -8,12 +8,10 @@ Lang = Literal[
|
|||||||
"es",
|
"es",
|
||||||
"fr",
|
"fr",
|
||||||
"id",
|
"id",
|
||||||
"it",
|
|
||||||
"jp",
|
"jp",
|
||||||
"kr",
|
"kr",
|
||||||
"pt",
|
"pt",
|
||||||
"ru",
|
"ru",
|
||||||
"th",
|
"th",
|
||||||
"tr",
|
|
||||||
"vi",
|
"vi",
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user