diff --git a/pyclasher/api/requests/__init__.py b/pyclasher/api/requests/__init__.py index d8f1a2d..00cbffd 100644 --- a/pyclasher/api/requests/__init__.py +++ b/pyclasher/api/requests/__init__.py @@ -31,6 +31,6 @@ # labels from .player_labels import PlayerLabelsRequest from .player_rankings import PlayerRankingsRequest -from .request_models import RequestModel, IterRequestModel, request_id +from .abc import RequestModel, IterRequestModel, request_id from .war_league import WarLeagueRequest from .war_leagues import WarLeaguesRequest diff --git a/pyclasher/api/requests/builder_base_league.py b/pyclasher/api/requests/builder_base_league.py index 8c36c3a..089d0fd 100644 --- a/pyclasher/api/requests/builder_base_league.py +++ b/pyclasher/api/requests/builder_base_league.py @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import BuilderBaseLeague diff --git a/pyclasher/api/requests/builder_base_league.pyi b/pyclasher/api/requests/builder_base_league.pyi index 7989284..c858ea4 100644 --- a/pyclasher/api/requests/builder_base_league.pyi +++ b/pyclasher/api/requests/builder_base_league.pyi @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import BuilderBaseLeague diff --git a/pyclasher/api/requests/builder_base_leagues.py b/pyclasher/api/requests/builder_base_leagues.py index 3de8b97..187de10 100644 --- a/pyclasher/api/requests/builder_base_leagues.py +++ b/pyclasher/api/requests/builder_base_leagues.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import BuilderBaseLeagueList, BuilderBaseLeague diff --git a/pyclasher/api/requests/builder_base_leagues.pyi b/pyclasher/api/requests/builder_base_leagues.pyi index e651f97..1f60f46 100644 --- a/pyclasher/api/requests/builder_base_leagues.pyi +++ b/pyclasher/api/requests/builder_base_leagues.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import BuilderBaseLeagueList, BuilderBaseLeague diff --git a/pyclasher/api/requests/capital_league.py b/pyclasher/api/requests/capital_league.py index c7c184e..7a20017 100644 --- a/pyclasher/api/requests/capital_league.py +++ b/pyclasher/api/requests/capital_league.py @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import CapitalLeague diff --git a/pyclasher/api/requests/capital_league.pyi b/pyclasher/api/requests/capital_league.pyi index 95a1095..207c73b 100644 --- a/pyclasher/api/requests/capital_league.pyi +++ b/pyclasher/api/requests/capital_league.pyi @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import CapitalLeague diff --git a/pyclasher/api/requests/capital_league_seasons.py b/pyclasher/api/requests/capital_league_seasons.py index 5cd381c..b35a35a 100644 --- a/pyclasher/api/requests/capital_league_seasons.py +++ b/pyclasher/api/requests/capital_league_seasons.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import CapitalLeagueList, CapitalLeague diff --git a/pyclasher/api/requests/capital_league_seasons.pyi b/pyclasher/api/requests/capital_league_seasons.pyi index 88e77f6..3194e6a 100644 --- a/pyclasher/api/requests/capital_league_seasons.pyi +++ b/pyclasher/api/requests/capital_league_seasons.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import CapitalLeagueList, CapitalLeague diff --git a/pyclasher/api/requests/clan.py b/pyclasher/api/requests/clan.py index f70a2b9..d5a4606 100644 --- a/pyclasher/api/requests/clan.py +++ b/pyclasher/api/requests/clan.py @@ -1,6 +1,6 @@ from asyncio import get_running_loop, run -from .request_models import RequestModel +from .abc import RequestModel from ..models import Clan, BaseClan diff --git a/pyclasher/api/requests/clan.pyi b/pyclasher/api/requests/clan.pyi index 1082b45..c93b858 100644 --- a/pyclasher/api/requests/clan.pyi +++ b/pyclasher/api/requests/clan.pyi @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import Clan, BaseClan diff --git a/pyclasher/api/requests/clan_builder_base_rankings.py b/pyclasher/api/requests/clan_builder_base_rankings.py index b712beb..0b05581 100644 --- a/pyclasher/api/requests/clan_builder_base_rankings.py +++ b/pyclasher/api/requests/clan_builder_base_rankings.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanBuilderBaseRanking, ClanBuilderBaseRankingList diff --git a/pyclasher/api/requests/clan_builder_base_rankings.pyi b/pyclasher/api/requests/clan_builder_base_rankings.pyi index b0eac04..4cb4ba2 100644 --- a/pyclasher/api/requests/clan_builder_base_rankings.pyi +++ b/pyclasher/api/requests/clan_builder_base_rankings.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanBuilderBaseRanking, ClanBuilderBaseRankingList, Location diff --git a/pyclasher/api/requests/clan_capital_raid_seasons.py b/pyclasher/api/requests/clan_capital_raid_seasons.py index a7cec55..7ef7a89 100644 --- a/pyclasher/api/requests/clan_capital_raid_seasons.py +++ b/pyclasher/api/requests/clan_capital_raid_seasons.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanCapitalRaidSeasons, ClanCapitalRaidSeason diff --git a/pyclasher/api/requests/clan_capital_raid_seasons.pyi b/pyclasher/api/requests/clan_capital_raid_seasons.pyi index 03fe475..3c21800 100644 --- a/pyclasher/api/requests/clan_capital_raid_seasons.pyi +++ b/pyclasher/api/requests/clan_capital_raid_seasons.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanCapitalRaidSeasons, ClanCapitalRaidSeason diff --git a/pyclasher/api/requests/clan_current_war.py b/pyclasher/api/requests/clan_current_war.py index ccb7609..12fdfde 100644 --- a/pyclasher/api/requests/clan_current_war.py +++ b/pyclasher/api/requests/clan_current_war.py @@ -1,6 +1,6 @@ from asyncio import get_running_loop, run -from .request_models import RequestModel +from .abc import RequestModel from ..models import ClanWar, BaseClan diff --git a/pyclasher/api/requests/clan_current_war.pyi b/pyclasher/api/requests/clan_current_war.pyi index 917b15d..a722d31 100644 --- a/pyclasher/api/requests/clan_current_war.pyi +++ b/pyclasher/api/requests/clan_current_war.pyi @@ -1,6 +1,6 @@ from typing import Coroutine, Any -from .request_models import RequestModel +from .abc import RequestModel from ..models import ClanWar, BaseClan diff --git a/pyclasher/api/requests/clan_labels.py b/pyclasher/api/requests/clan_labels.py index ee816c1..e612041 100644 --- a/pyclasher/api/requests/clan_labels.py +++ b/pyclasher/api/requests/clan_labels.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import LabelList, Label diff --git a/pyclasher/api/requests/clan_labels.pyi b/pyclasher/api/requests/clan_labels.pyi index e5ba598..80028d2 100644 --- a/pyclasher/api/requests/clan_labels.pyi +++ b/pyclasher/api/requests/clan_labels.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import LabelList, Label diff --git a/pyclasher/api/requests/clan_members.py b/pyclasher/api/requests/clan_members.py index 25459aa..0c49806 100644 --- a/pyclasher/api/requests/clan_members.py +++ b/pyclasher/api/requests/clan_members.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanMember, ClanMemberList diff --git a/pyclasher/api/requests/clan_members.pyi b/pyclasher/api/requests/clan_members.pyi index eb41d91..2a69a6d 100644 --- a/pyclasher/api/requests/clan_members.pyi +++ b/pyclasher/api/requests/clan_members.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanMember, ClanMemberList diff --git a/pyclasher/api/requests/clan_rankings.py b/pyclasher/api/requests/clan_rankings.py index 81f1faa..71fa342 100644 --- a/pyclasher/api/requests/clan_rankings.py +++ b/pyclasher/api/requests/clan_rankings.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanRanking, ClanRankingList diff --git a/pyclasher/api/requests/clan_rankings.pyi b/pyclasher/api/requests/clan_rankings.pyi index eafd39f..e4a8348 100644 --- a/pyclasher/api/requests/clan_rankings.pyi +++ b/pyclasher/api/requests/clan_rankings.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanRanking, ClanRankingList, Location diff --git a/pyclasher/api/requests/clan_search.py b/pyclasher/api/requests/clan_search.py index b7e08d9..f9b6a60 100644 --- a/pyclasher/api/requests/clan_search.py +++ b/pyclasher/api/requests/clan_search.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanList, WarFrequency, Locations, Labels, Clan diff --git a/pyclasher/api/requests/clan_search.pyi b/pyclasher/api/requests/clan_search.pyi index f798b27..c50e0d7 100644 --- a/pyclasher/api/requests/clan_search.pyi +++ b/pyclasher/api/requests/clan_search.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanList, WarFrequency, Locations, Labels, Clan diff --git a/pyclasher/api/requests/clan_war_log.py b/pyclasher/api/requests/clan_war_log.py index a2ed223..5deabe5 100644 --- a/pyclasher/api/requests/clan_war_log.py +++ b/pyclasher/api/requests/clan_war_log.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanWarLog, ClanWarLogEntry diff --git a/pyclasher/api/requests/clan_war_log.pyi b/pyclasher/api/requests/clan_war_log.pyi index 237d5dc..f0e41ac 100644 --- a/pyclasher/api/requests/clan_war_log.pyi +++ b/pyclasher/api/requests/clan_war_log.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import ClanWarLog, ClanWarLogEntry diff --git a/pyclasher/api/requests/gold_pass.py b/pyclasher/api/requests/gold_pass.py index 5f54624..dea66fb 100644 --- a/pyclasher/api/requests/gold_pass.py +++ b/pyclasher/api/requests/gold_pass.py @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import GoldPassSeason diff --git a/pyclasher/api/requests/gold_pass.pyi b/pyclasher/api/requests/gold_pass.pyi index 518d33e..859e0b4 100644 --- a/pyclasher/api/requests/gold_pass.pyi +++ b/pyclasher/api/requests/gold_pass.pyi @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import GoldPassSeason diff --git a/pyclasher/api/requests/league.py b/pyclasher/api/requests/league.py index 26100e8..a86d5b5 100644 --- a/pyclasher/api/requests/league.py +++ b/pyclasher/api/requests/league.py @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import League diff --git a/pyclasher/api/requests/league.pyi b/pyclasher/api/requests/league.pyi index 21039b9..410b31e 100644 --- a/pyclasher/api/requests/league.pyi +++ b/pyclasher/api/requests/league.pyi @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import League diff --git a/pyclasher/api/requests/league_season.py b/pyclasher/api/requests/league_season.py index 23757a9..3c71413 100644 --- a/pyclasher/api/requests/league_season.py +++ b/pyclasher/api/requests/league_season.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import PlayerRanking, PlayerRankingList, Season diff --git a/pyclasher/api/requests/league_season.pyi b/pyclasher/api/requests/league_season.pyi index 3b8b93c..23a53e5 100644 --- a/pyclasher/api/requests/league_season.pyi +++ b/pyclasher/api/requests/league_season.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import PlayerRanking, PlayerRankingList, Leagues, Season diff --git a/pyclasher/api/requests/leagues.py b/pyclasher/api/requests/leagues.py index 32b4db9..e69c1dc 100644 --- a/pyclasher/api/requests/leagues.py +++ b/pyclasher/api/requests/leagues.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import LeagueList, League diff --git a/pyclasher/api/requests/leagues.pyi b/pyclasher/api/requests/leagues.pyi index e4381c2..fec0658 100644 --- a/pyclasher/api/requests/leagues.pyi +++ b/pyclasher/api/requests/leagues.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import LeagueList, League diff --git a/pyclasher/api/requests/location.py b/pyclasher/api/requests/location.py index 3ccb69b..3727b84 100644 --- a/pyclasher/api/requests/location.py +++ b/pyclasher/api/requests/location.py @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import Location diff --git a/pyclasher/api/requests/location.pyi b/pyclasher/api/requests/location.pyi index e990e18..1de39fd 100644 --- a/pyclasher/api/requests/location.pyi +++ b/pyclasher/api/requests/location.pyi @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import Location diff --git a/pyclasher/api/requests/locations.py b/pyclasher/api/requests/locations.py index 17a86ed..8e5c840 100644 --- a/pyclasher/api/requests/locations.py +++ b/pyclasher/api/requests/locations.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import Location, LocationList diff --git a/pyclasher/api/requests/locations.pyi b/pyclasher/api/requests/locations.pyi index d7fc5f3..6cdb202 100644 --- a/pyclasher/api/requests/locations.pyi +++ b/pyclasher/api/requests/locations.pyi @@ -1,6 +1,6 @@ from typing import Self, Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import Location, LocationList diff --git a/pyclasher/api/requests/player.py b/pyclasher/api/requests/player.py index f0bb31c..a4166a7 100644 --- a/pyclasher/api/requests/player.py +++ b/pyclasher/api/requests/player.py @@ -1,7 +1,7 @@ from asyncio import Future, get_running_loop, run from urllib.parse import quote -from .request_models import RequestModel +from .abc import RequestModel from ..models import Player, VerifyTokenRequest, VerifyTokenResponse from ...utils.request_methods import RequestMethods from ...exceptions import ClientIsNotRunning, ApiCode diff --git a/pyclasher/api/requests/player.pyi b/pyclasher/api/requests/player.pyi index 39147e2..1cee5b7 100644 --- a/pyclasher/api/requests/player.pyi +++ b/pyclasher/api/requests/player.pyi @@ -1,6 +1,6 @@ from typing import Coroutine, Any -from .request_models import RequestModel +from .abc import RequestModel from ..models import Player, VerifyTokenResponse diff --git a/pyclasher/api/requests/player_builder_base_rankings.py b/pyclasher/api/requests/player_builder_base_rankings.py index aa70ec5..8b9b97e 100644 --- a/pyclasher/api/requests/player_builder_base_rankings.py +++ b/pyclasher/api/requests/player_builder_base_rankings.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import PlayerBuilderBaseRanking, PlayerBuilderBaseRankingList diff --git a/pyclasher/api/requests/player_builder_base_rankings.pyi b/pyclasher/api/requests/player_builder_base_rankings.pyi index 94eedbd..06907d9 100644 --- a/pyclasher/api/requests/player_builder_base_rankings.pyi +++ b/pyclasher/api/requests/player_builder_base_rankings.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import PlayerBuilderBaseRanking, PlayerBuilderBaseRankingList, Location diff --git a/pyclasher/api/requests/player_labels.py b/pyclasher/api/requests/player_labels.py index 2ac1350..1bef6e0 100644 --- a/pyclasher/api/requests/player_labels.py +++ b/pyclasher/api/requests/player_labels.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import LabelList, Label diff --git a/pyclasher/api/requests/player_labels.pyi b/pyclasher/api/requests/player_labels.pyi index 21588d0..cd57aff 100644 --- a/pyclasher/api/requests/player_labels.pyi +++ b/pyclasher/api/requests/player_labels.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import LabelList, Label diff --git a/pyclasher/api/requests/player_rankings.py b/pyclasher/api/requests/player_rankings.py index 5f06da2..7b0831d 100644 --- a/pyclasher/api/requests/player_rankings.py +++ b/pyclasher/api/requests/player_rankings.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import PlayerRanking, PlayerRankingList diff --git a/pyclasher/api/requests/player_rankings.pyi b/pyclasher/api/requests/player_rankings.pyi index cbb234b..cd1a569 100644 --- a/pyclasher/api/requests/player_rankings.pyi +++ b/pyclasher/api/requests/player_rankings.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import PlayerRanking, PlayerRankingList, Location diff --git a/pyclasher/api/requests/war_league.py b/pyclasher/api/requests/war_league.py index a008cb7..13002e3 100644 --- a/pyclasher/api/requests/war_league.py +++ b/pyclasher/api/requests/war_league.py @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import WarLeague diff --git a/pyclasher/api/requests/war_league.pyi b/pyclasher/api/requests/war_league.pyi index 47a2429..a6396f0 100644 --- a/pyclasher/api/requests/war_league.pyi +++ b/pyclasher/api/requests/war_league.pyi @@ -1,4 +1,4 @@ -from .request_models import RequestModel +from .abc import RequestModel from ..models import WarLeague diff --git a/pyclasher/api/requests/war_leagues.py b/pyclasher/api/requests/war_leagues.py index d228b8b..b98b890 100644 --- a/pyclasher/api/requests/war_leagues.py +++ b/pyclasher/api/requests/war_leagues.py @@ -1,4 +1,4 @@ -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import WarLeagueList, WarLeague diff --git a/pyclasher/api/requests/war_leagues.pyi b/pyclasher/api/requests/war_leagues.pyi index 043fa19..02bbb6a 100644 --- a/pyclasher/api/requests/war_leagues.pyi +++ b/pyclasher/api/requests/war_leagues.pyi @@ -1,6 +1,6 @@ from typing import Iterator -from .request_models import IterRequestModel +from .abc import IterRequestModel from ..models import WarLeagueList, WarLeague diff --git a/pyclasher/client.py b/pyclasher/client.py index 184a18c..eef7f21 100644 --- a/pyclasher/client.py +++ b/pyclasher/client.py @@ -1,4 +1,4 @@ -from asyncio import run, create_task, get_running_loop, new_event_loop +from asyncio import create_task from typing import Iterable from urllib.parse import urlparse @@ -83,10 +83,6 @@ async def from_login(cls, email, password, requests_per_second=5, self.__temporary_session = True return self - @property - def is_running(self) -> bool: - return self.__client_running - async def start(self, tokens=None): if tokens is None: tokens = self.__tokens @@ -153,3 +149,7 @@ def __del__(self): self.logger.warning("The client was still running, closed now.") return + + @property + def is_running(self) -> bool: + return self.__client_running diff --git a/pyclasher/client.pyi b/pyclasher/client.pyi index eb3994b..be3ddf6 100644 --- a/pyclasher/client.pyi +++ b/pyclasher/client.pyi @@ -1,66 +1,47 @@ -from asyncio import Queue, Future, Task, AbstractEventLoop -from enum import Enum from logging import Logger -from typing import Iterable, Coroutine, Any +from typing import Iterable -from aiohttp import ClientSession - -from .api.models import BaseModel from .exceptions import MISSING +from .request_queue import PcQueue - - - - - - -class PyClasherClient: +class Client: """ this is the class for the ClashOfClans API client :cvar __instance: the private instance of the client - :type __instance: PyClasherClient + :type __instance: Client :cvar base_url: the public base URL for the requests (usually https://api.clashofclans.com) :type base_url: str :cvar endpoint: the public endpoint URL for the requests (usually /v1) :type endpoint: str - :cvar queue: the public request_queue where the requests are enqueued - :type queue: RequestQueue :cvar requests_per_second: the public number of requests done per consumer/token per second (usually 5) :type requests_per_second: int :cvar logger: public logger to log the requests, ... (usually MISSING) :type logger: Logger :cvar initialised: public boolean that indicates if the :type initialised: bool - :cvar __loop: abstract event loop that is used for making requests if no loop is running - :type __loop: AbstractEventLoop - :cvar __consumers: private list of consumers of the request_queue and requests + :ivar queue: the public request_queue where the requests are enqueued + :type queue: RequestQueue + :ivar __consumers: private list of consumers of the request_queue and requests :type __consumers: list[Consumer] - :cvar __consume_tasks: private list of tasks of the consumer + :ivar __consume_tasks: private list of tasks of the consumer :type __consume_tasks: list[Task] - :cvar __temporary_session: private boolean that indicates if the session is temporary or not + :ivar __temporary_session: private boolean that indicates if the session is temporary or not :type __temporary_session: bool - :cvar __tokens: private list of tokens + :ivar __tokens: private list of tokens :type __tokens: list[str] - :cvar __client_running: private boolean that indicates if the client is running or not + :ivar __client_running: private boolean that indicates if the client is running or not :type __client_running: bool """ - __instance: PyClasherClient = None + __instance: Client = None base_url: str = "https://api.clashofclans.com" endpoint: str = "/v1" - queue: RequestQueue = None requests_per_second: int = 5 logger: Logger = MISSING initialised = False - __loop: AbstractEventLoop = MISSING - __consumers: list[Consumer] = None - __consume_tasks: list[Task] = None - __temporary_session: bool = False - __tokens: list[str] | None = None - __client_running: bool = False def __new__(cls, *args, **kwargs): ... @@ -93,18 +74,26 @@ class PyClasherClient: :return: None :rtype: None """ - self.request_timeout = request_timeout + self.logger: Logger = ... + self.__tokens: list[str] = ... + self.requests_per_second: int = ... + self.queue: PcQueue = ... + self.request_timeout: float = ... + self.__client_running: bool = ... + self.__temporary_session: bool = ... + self.__consumers: list = ... + self.__consume_tasks: list = ... ... @classmethod - def from_login(cls, - email: str, - password: str, - requests_per_second: int = 5, - request_timeout: float = 30, - logger: Logger = MISSING, - login_count: int = 1 - ) -> PyClasherClient | Coroutine[Any, Any, PyClasherClient]: + async def from_login(cls, + email: str, + password: str, + requests_per_second: int = 5, + request_timeout: float = 30, + logger: Logger = MISSING, + login_count: int = 1 + ) -> Client: """ login via the ClashOfClans login API to retrieve a temporary session (usually 1 hour) @@ -113,26 +102,17 @@ class PyClasherClient: :param requests_per_second: number of requests per token per second :param request_timeout: seconds until the request is cancelled due to a timeout :param logger: logger - :param login_count: number of logins that should be done (having more logins results more tokens and this leads to more requests that can be executed in parallel) - .. note:: do not set the ``login_count`` to high, otherwise the account could be banned (5 works fine) - :return: an instance of the pyclasher client or a coroutine that returns an instance of the pyclasher client - :rtype: PyClasherClient | Coroutine[Any, Any, PyClasherClient] + :param login_count: number of logins that should be done (having more logins results more tokens + and this leads to more requests that can be executed in parallel) + .. note:: do not set the ``login_count`` to high, otherwise the account could be banned + (5 works fine) + :return: an instance of the pyclasher client or a coroutine that returns an instance of + the pyclasher client + :rtype: Client """ ... - @property - def is_running(self) -> bool: - """ - property that indicates if the client is running - - status changes if the client is started or stopped - - :return: boolean indicating if the client is running, True if running else otherwise - :rtype: bool - """ - ... - - def start(self, tokens: str | Iterable[str] = None) -> PyClasherClient: + async def start(self, tokens: str | Iterable[str] = None) -> Client: """ start the client @@ -143,36 +123,32 @@ class PyClasherClient: """ ... - def close(self) -> PyClasherClient | Coroutine[Any, Any, PyClasherClient]: + async def close(self) -> Client: """ close the client - this method can be used in an asynchronous context using the ``await`` keyword - but can also be used in non-asynchronous context without awaiting the method - :return: the instance of the client - :rtype: PyClasherClient | Coroutine[Any, Any, PyClasherClient] + :rtype: Client """ ... - def __enter__(self) -> PyClasherClient: + async def __aenter__(self) -> Client: ... - def __exit__(self, exc_type, exc_val, exc_tb) -> PyClasherClient: - ... - - async def __aenter__(self) -> PyClasherClient: - ... - - async def __aexit__(self, exc_type, exc_val, exc_tb) -> PyClasherClient: + async def __aexit__(self, exc_type, exc_val, exc_tb) -> Client: ... def __del__(self) -> None: ... @property - def loop(self) -> AbstractEventLoop: - ... + def is_running(self) -> bool: + """ + property that indicates if the client is running + + status changes if the client is started or stopped - def reset_client(self, reset_queue: bool = True, reset_loop: bool = True, reset_tokens: bool = True) -> None: + :return: boolean indicating if the client is running, True if running else otherwise + :rtype: bool + """ ...