diff --git a/pyclasher/__init__.py b/pyclasher/__init__.py index 1a2f304..11d603d 100644 --- a/pyclasher/__init__.py +++ b/pyclasher/__init__.py @@ -11,15 +11,35 @@ __version__ = '1.0.0' -from .api import * +from .api.bulk_requests import * +from .api.requests import * from .client import Client from .exceptions import ( - PyClasherException, ApiException, ApiExceptions, UnknownApiException, - MISSING, Missing, RequestNotDone, RequestTimeout, BadRequest, NotFound, - Throttled, Maintenance, AccessDenied, NoClient, InvalidClientId, - ClientIsRunning, ClientIsNotRunning, ClientRunningOverwrite, - ClientAlreadyInitialised, LoginNotDone, InvalidLoginData, InvalidType, - InvalidTimeFormat, InvalidSeasonFormat, NoneToken + PyClasherException, + ApiException, + ApiExceptions, + UnknownApiException, + MISSING, + Missing, + RequestNotDone, + RequestTimeout, + BadRequest, + NotFound, + Throttled, + Maintenance, + AccessDenied, + NoClient, + InvalidClientId, + ClientIsRunning, + ClientIsNotRunning, + ClientRunningOverwrite, + ClientAlreadyInitialised, + LoginNotDone, + InvalidLoginData, + InvalidType, + InvalidTimeFormat, + InvalidSeasonFormat, + NoneToken ) __all__ = ( diff --git a/pyclasher/client/client.py b/pyclasher/client/client.py index 6800b73..b83496c 100644 --- a/pyclasher/client/client.py +++ b/pyclasher/client/client.py @@ -18,6 +18,11 @@ from pyclasher.utils.login import Login +__all__ = ( + 'Client', +) + + global_client_id = 0 """Global variable for counting and identifying clients""" diff --git a/pyclasher/client/client.pyi b/pyclasher/client/client.pyi index 610f6ed..29808aa 100644 --- a/pyclasher/client/client.pyi +++ b/pyclasher/client/client.pyi @@ -5,6 +5,12 @@ from typing import Iterable from ..exceptions import MISSING from .request_queue import PQueue + +__all__ = ( + 'Client', +) + + global_client_id: int = ... diff --git a/pyclasher/client/request_consumer.py b/pyclasher/client/request_consumer.py index b968444..dfa177b 100644 --- a/pyclasher/client/request_consumer.py +++ b/pyclasher/client/request_consumer.py @@ -8,6 +8,11 @@ from pyclasher.utils import ExecutionTimer +__all__ = ( + 'PConsumer', +) + + class PConsumer: def __init__(self, queue, token, requests_per_s, request_timeout, url): self.queue = queue @@ -55,7 +60,6 @@ async def _request(self, future, url, method, body, status, error): error.set_result(exception) raise exception - async def consume(self): while True: future, url, method, body, status, error = await self.queue.get() diff --git a/pyclasher/client/request_consumer.pyi b/pyclasher/client/request_consumer.pyi index a5b8aed..322dedf 100644 --- a/pyclasher/client/request_consumer.pyi +++ b/pyclasher/client/request_consumer.pyi @@ -5,6 +5,11 @@ from aiohttp import ClientSession from .request_queue import PQueue +__all__ = ( + 'PConsumer', +) + + class PConsumer: """ consumer class that consumes the requests and returns the responses of the ClashOfClans API diff --git a/pyclasher/client/request_queue.py b/pyclasher/client/request_queue.py index e940541..7d76802 100644 --- a/pyclasher/client/request_queue.py +++ b/pyclasher/client/request_queue.py @@ -1,6 +1,11 @@ from asyncio import Queue +__all__ = ( + 'PQueue', +) + + class PQueue(Queue): async def put(self, future, diff --git a/pyclasher/client/request_queue.pyi b/pyclasher/client/request_queue.pyi index 1f40656..4f6e0b8 100644 --- a/pyclasher/client/request_queue.pyi +++ b/pyclasher/client/request_queue.pyi @@ -3,6 +3,11 @@ from asyncio import Queue, Future from ..utils.request_methods import RequestMethods +__all__ = ( + 'PQueue', +) + + class PQueue(Queue): async def put(self, future: Future, diff --git a/pyclasher/exceptions.py b/pyclasher/exceptions.py index cd61ebe..4133bc6 100644 --- a/pyclasher/exceptions.py +++ b/pyclasher/exceptions.py @@ -6,6 +6,35 @@ """ +__all__ = ( + 'PyClasherException', + 'Missing', + 'MISSING', + 'LoginNotDone', + 'RequestTimeout', + 'InvalidLoginData', + 'NotFound', + 'BadRequest', + 'AccessDenied', + 'ApiException', + 'Throttled', + 'Maintenance', + 'NoClient', + 'NoneToken', + 'InvalidType', + 'UnknownApiException', + 'ApiExceptions', + 'InvalidClientId', + 'ClientIsRunning', + 'RequestNotDone', + 'InvalidTimeFormat', + 'InvalidSeasonFormat', + 'ClientIsNotRunning', + 'ClientRunningOverwrite', + 'ClientAlreadyInitialised', +) + + class Missing: """ Class of the ``MISSING`` object diff --git a/pyclasher/exceptions.pyi b/pyclasher/exceptions.pyi index 6f98c1e..3ff32e7 100644 --- a/pyclasher/exceptions.pyi +++ b/pyclasher/exceptions.pyi @@ -11,6 +11,35 @@ from typing import Any from .api.models import ClientError +__all__ = ( + 'PyClasherException', + 'Missing', + 'MISSING', + 'LoginNotDone', + 'RequestTimeout', + 'InvalidLoginData', + 'NotFound', + 'BadRequest', + 'AccessDenied', + 'ApiException', + 'Throttled', + 'Maintenance', + 'NoClient', + 'NoneToken', + 'InvalidType', + 'UnknownApiException', + 'ApiExceptions', + 'InvalidClientId', + 'ClientIsRunning', + 'RequestNotDone', + 'InvalidTimeFormat', + 'InvalidSeasonFormat', + 'ClientIsNotRunning', + 'ClientRunningOverwrite', + 'ClientAlreadyInitialised', +) + + class Missing: """ Class of the ``MISSING`` object diff --git a/pyclasher/utils/__init__.py b/pyclasher/utils/__init__.py index d8e0abd..68f5034 100644 --- a/pyclasher/utils/__init__.py +++ b/pyclasher/utils/__init__.py @@ -2,3 +2,11 @@ from .functions import snake_to_camel from .login import Login from .request_methods import RequestMethods + + +__all__ = ( + 'ExecutionTimer', + 'snake_to_camel', + 'Login', + 'RequestMethods', +) diff --git a/pyclasher/utils/exectimer.py b/pyclasher/utils/exectimer.py index 2daf760..f1b11c0 100644 --- a/pyclasher/utils/exectimer.py +++ b/pyclasher/utils/exectimer.py @@ -2,6 +2,11 @@ from time import perf_counter +__all__ = ( + 'ExecutionTimer', +) + + class ExecutionTimer: def __init__(self, min_time=0): self._min_time = min_time diff --git a/pyclasher/utils/exectimer.pyi b/pyclasher/utils/exectimer.pyi index 7d14c03..57ed23d 100644 --- a/pyclasher/utils/exectimer.pyi +++ b/pyclasher/utils/exectimer.pyi @@ -1,3 +1,8 @@ +__all__ = ( + 'ExecutionTimer', +) + + class ExecutionTimer: def __init__(self, min_time: float = 0) -> None: self._min_time = min_time diff --git a/pyclasher/utils/functions.py b/pyclasher/utils/functions.py index c32a304..09c1f66 100644 --- a/pyclasher/utils/functions.py +++ b/pyclasher/utils/functions.py @@ -1,3 +1,8 @@ +__all__ = ( + 'snake_to_camel', +) + + def snake_to_camel(snake_str: str) -> str: components = snake_str.split('_') camel_str = components[0] + ''.join( diff --git a/pyclasher/utils/functions.pyi b/pyclasher/utils/functions.pyi index 656dc05..9493635 100644 --- a/pyclasher/utils/functions.pyi +++ b/pyclasher/utils/functions.pyi @@ -1,2 +1,7 @@ +__all__ = ( + 'snake_to_camel', +) + + def snake_to_camel(snake_str: str) -> str: ... diff --git a/pyclasher/utils/login.py b/pyclasher/utils/login.py index bb24008..30de2a1 100644 --- a/pyclasher/utils/login.py +++ b/pyclasher/utils/login.py @@ -6,6 +6,11 @@ from ..exceptions import MISSING, LoginNotDone, InvalidLoginData +__all__ = ( + 'Login', +) + + class Login(LoginModel): login_url = "https://developer.clashofclans.com/api/login" __response = None diff --git a/pyclasher/utils/login.pyi b/pyclasher/utils/login.pyi index bdadfae..0c3a575 100644 --- a/pyclasher/utils/login.pyi +++ b/pyclasher/utils/login.pyi @@ -4,6 +4,11 @@ from ..api.models.login import LoginModel from ..exceptions import Missing +__all__ = ( + 'Login', +) + + class Login(LoginModel): """ class to log in via the ClashOfClans login API diff --git a/pyclasher/utils/request_methods.py b/pyclasher/utils/request_methods.py index 9679a2c..0b6a652 100644 --- a/pyclasher/utils/request_methods.py +++ b/pyclasher/utils/request_methods.py @@ -1,6 +1,11 @@ from enum import Enum +__all__ = ( + 'RequestMethods', +) + + class RequestMethods(Enum): REQUEST = "get" POST = "post" diff --git a/pyclasher/utils/request_methods.pyi b/pyclasher/utils/request_methods.pyi index 9679a2c..0b6a652 100644 --- a/pyclasher/utils/request_methods.pyi +++ b/pyclasher/utils/request_methods.pyi @@ -1,6 +1,11 @@ from enum import Enum +__all__ = ( + 'RequestMethods', +) + + class RequestMethods(Enum): REQUEST = "get" POST = "post"