mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-22 06:17:54 +00:00
🔥 删除无用代码
This commit is contained in:
parent
5c263ad83d
commit
6f16002faf
@ -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
|
||||||
|
@ -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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user