🔥 删除无用代码

This commit is contained in:
Karako 2022-09-20 23:54:35 +08:00
parent 5c263ad83d
commit 6f16002faf
No known key found for this signature in database
GPG Key ID: 5920831B0095D4A0
2 changed files with 6 additions and 22 deletions

View File

@ -11,11 +11,11 @@ from metadata.honey import HONEY_RESERVED_ID_MAP
from metadata.shortname import roleToId, roles from metadata.shortname import roleToId, roles
from modules.wiki.base import SCRAPE_HOST from modules.wiki.base import SCRAPE_HOST
from utils.const import PROJECT_ROOT from utils.const import PROJECT_ROOT
from utils.helpers import mkdir from utils.log import logger
from utils.typedefs import StrOrURL from utils.typedefs import StrOrURL
ASSETS_PATH = PROJECT_ROOT.joinpath('resources/assets') ASSETS_PATH = PROJECT_ROOT.joinpath('resources/assets')
ASSETS_PATH.mkdir(exist_ok=True) ASSETS_PATH.mkdir(exist_ok=True, parents=True)
class _AssetsService(ABC): class _AssetsService(ABC):
@ -26,7 +26,9 @@ class _AssetsService(ABC):
@property @property
def path(self) -> Path: def path(self) -> Path:
return mkdir(self._dir.joinpath(self.id)) path = self._dir.joinpath(self.id)
path.mkdir(exist_ok=True, parents=True)
return path
def __init__(self, client: AsyncClient): def __init__(self, client: AsyncClient):
self._client = client self._client = client

View File

@ -1,7 +1,7 @@
import hashlib import hashlib
import os import os
from pathlib import Path from pathlib import Path
from typing import Iterator, Optional, Tuple, Union, cast from typing import Optional, Tuple, Union, cast
import aiofiles import aiofiles
import genshin import genshin
@ -130,21 +130,3 @@ def region_server(uid: Union[int, str]) -> RegionEnum:
return region return region
else: else:
raise TypeError(f"UID {uid} isn't associated with any region") raise TypeError(f"UID {uid} isn't associated with any region")
def mkdir(path: Path) -> Path:
"""根据路径依次创建文件夹"""
path_list = []
parent = path.parent if path.suffix else path
while not parent.exists():
path_list.append(parent)
try:
parent.mkdir(exist_ok=True)
except FileNotFoundError:
parent = parent.parent
while path_list:
path_list.pop().mkdir(exist_ok=True)
return path