🎨 Organize client subdirectories and add __all__ variable

Moves all subdirectories from 'simnet/client' to 'simnet/client/components' and adds the `__all__` variable to all affected files.

This change is intended to improve code organization and make it easier to manage exported symbols from these modules.
This commit is contained in:
洛水居室 2023-05-05 20:04:41 +08:00 committed by GitHub
parent 098c022a55
commit 14b107b5a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 61 additions and 25 deletions

View File

@ -21,6 +21,8 @@ from simnet.utils.types import (
_LOGGER = logging.getLogger("SIMNet.BaseClient")
__all__ = ("BaseClient",)
class BaseClient(AsyncContextManager["BaseClient"]):
"""

View File

@ -10,6 +10,8 @@ from simnet.client.routes import (
)
from simnet.utils.enum_ import Region
__all__ = ("AuthClient",)
class AuthClient(BaseClient):
"""

View File

@ -4,6 +4,8 @@ from simnet.client.routes import RECORD_URL
from simnet.utils.enum_ import Region, Game
from simnet.utils.types import QueryParamTypes
__all__ = ("BaseChronicleClient",)
class BaseChronicleClient(BaseClient):
"""The base class for the Chronicle API client.

View File

@ -1,7 +1,7 @@
import asyncio
from typing import Optional, Any, List, Dict
from simnet.client.chronicle.base import BaseChronicleClient
from simnet.client.components.chronicle.base import BaseChronicleClient
from simnet.errors import DataNotPublic, BadRequest
from simnet.models.genshin.chronicle.abyss import SpiralAbyss, SpiralAbyssPair
from simnet.models.genshin.chronicle.characters import Character
@ -14,8 +14,10 @@ from simnet.models.genshin.chronicle.stats import (
from simnet.utils.enum_ import Game
from simnet.utils.player import recognize_genshin_server, recognize_region
__all__ = ("GenshinBattleChronicleClient",)
class GenshinChronicleClient(BaseChronicleClient):
class GenshinBattleChronicleClient(BaseChronicleClient):
"""A client for retrieving data from Genshin's battle chronicle component.
This class is used to retrieve various data objects from StarRail's battle chronicle component,

View File

@ -1,6 +1,6 @@
from typing import Optional, Mapping, Dict, Any
from simnet.client.chronicle.base import BaseChronicleClient
from simnet.client.components.chronicle.base import BaseChronicleClient
from simnet.errors import BadRequest, DataNotPublic
from simnet.models.starrail.chronicle.characters import StarShipDetailCharacters
from simnet.models.starrail.chronicle.notes import StarRailNote
@ -8,6 +8,8 @@ from simnet.models.starrail.chronicle.stats import StarRailUserStats
from simnet.utils.enum_ import Game
from simnet.utils.player import recognize_starrail_server, recognize_region
__all__ = ("StarRailBattleChronicleClient",)
class StarRailBattleChronicleClient(BaseChronicleClient):
"""A client for retrieving data from StarRail's battle chronicle component.

View File

@ -6,6 +6,8 @@ from simnet.client.routes import GACHA_INFO_URL
from simnet.utils.enum_ import Game
from simnet.utils.lang import create_short_lang_code
__all__ = ("BaseWishClient",)
class BaseWishClient(BaseClient):
"""The base class for the Wish API client."""

View File

@ -1,14 +1,17 @@
from functools import partial
from typing import Optional, List
from simnet.client.wish.base import BaseWishClient
from simnet.client.components.wish.base import BaseWishClient
from simnet.models.genshin.wish import Wish
from simnet.utils.enum_ import Game
from simnet.utils.paginator import WishPaginator
class WishClient(BaseWishClient):
"""The WishClient class for making requests towards the Wish API."""
__all__ = ("GenshinWishClient",)
class GenshinWishClient(BaseWishClient):
"""The GenshinWishClient class for making requests towards the Wish API."""
async def wish_history(
self,

View File

@ -1,13 +1,15 @@
from functools import partial
from typing import Optional, List
from simnet.client.wish.base import BaseWishClient
from simnet.client.components.wish.base import BaseWishClient
from simnet.models.starrail.wish import StarRailWish
from simnet.utils.enum_ import Game
from simnet.utils.paginator import WishPaginator
__all__ = ("StarRailWishClient",)
class WishClient(BaseWishClient):
"""The WishClient class for making requests towards the Wish API."""
class StarRailWishClient(BaseWishClient):
"""The StarRailWishClient class for making requests towards the Wish API."""
async def wish_history(
self,

View File

@ -2,6 +2,8 @@ from typing import Optional
from httpx import Cookies as _Cookies
__all__ = ("Cookies",)
class Cookies(_Cookies):
"""An extension of the `httpx.Cookies` class that includes additional functionality."""

View File

@ -1,9 +1,9 @@
from simnet.client.account.auth import AuthClient
from simnet.client.chronicle.genshin import GenshinChronicleClient
from simnet.client.wish.genshin import WishClient
from simnet.client.components.auth import AuthClient
from simnet.client.components.chronicle.genshin import GenshinBattleChronicleClient
from simnet.client.components.wish.genshin import GenshinWishClient
__all__ = ("GenshinClient",)
class GenshinClient(GenshinChronicleClient, WishClient, AuthClient):
class GenshinClient(GenshinBattleChronicleClient, GenshinWishClient, AuthClient):
"""A simple http client for StarRail endpoints."""

View File

@ -1,12 +1,12 @@
from typing import Optional
from simnet.client.account.auth import AuthClient
from simnet.client.chronicle.genshin import GenshinChronicleClient
from simnet.client.wish.genshin import WishClient
from simnet.client.components.auth import AuthClient
from simnet.client.components.chronicle.genshin import GenshinBattleChronicleClient
from simnet.client.components.wish.genshin import GenshinWishClient
from simnet.utils.enum_ import Region
from simnet.utils.types import CookieTypes, HeaderTypes, TimeoutTypes
class GenshinClient(GenshinChronicleClient, WishClient, AuthClient):
class GenshinClient(GenshinBattleChronicleClient, GenshinWishClient, AuthClient):
def __init__(
self,
cookies: Optional[CookieTypes] = None,

View File

@ -1,5 +1,7 @@
from httpx import Headers as _Headers
__all__ = ("Headers",)
class Headers(_Headers):
"""An extension of the `httpx.Headers` class that includes additional functionality."""

View File

@ -7,6 +7,21 @@ from simnet.utils.enum_ import Region, Game
URLTypes = Union["URL", str]
__all__ = (
"URL",
"BaseRoute",
"Route",
"InternationalRoute",
"GameRoute",
"RECORD_URL",
"GACHA_INFO_URL",
"AUTH_URL",
"GET_COOKIES_TOKEN_BY_STOKEN_URL",
"GET_LTOKEN_BY_STOKEN_URL",
"AUTH_KEY_URL",
"HK4E_LOGIN_URL",
)
class URL(_URL):
"""A subclass of httpx's URL class, with additional convenience methods for URL manipulation."""

View File

@ -1,9 +1,9 @@
from simnet.client.account.auth import AuthClient
from simnet.client.chronicle.starrail import StarRailBattleChronicleClient
from simnet.client.wish.starrail import WishClient
from simnet.client.components.auth import AuthClient
from simnet.client.components.chronicle.starrail import StarRailBattleChronicleClient
from simnet.client.components.wish.starrail import StarRailWishClient
__all__ = ("StarRailClient",)
class StarRailClient(StarRailBattleChronicleClient, WishClient, AuthClient):
class StarRailClient(StarRailBattleChronicleClient, StarRailWishClient, AuthClient):
"""A simple http client for StarRail endpoints."""

View File

@ -1,12 +1,12 @@
from typing import Optional
from simnet.client.account.auth import AuthClient
from simnet.client.chronicle.starrail import StarRailBattleChronicleClient
from simnet.client.wish.starrail import WishClient
from simnet.client.components.auth import AuthClient
from simnet.client.components.chronicle.starrail import StarRailBattleChronicleClient
from simnet.client.components.wish.starrail import StarRailWishClient
from simnet.utils.enum_ import Region
from simnet.utils.types import CookieTypes, HeaderTypes, TimeoutTypes
class StarRailClient(StarRailBattleChronicleClient, WishClient, AuthClient):
class StarRailClient(StarRailBattleChronicleClient, StarRailWishClient, AuthClient):
def __init__(
self,
cookies: Optional[CookieTypes] = None,