Skip to content

Commit

Permalink
Merge pull request #62 from 201st-Luka/unstable
Browse files Browse the repository at this point in the history
rebase before publishing
  • Loading branch information
201st-Luka authored Oct 2, 2023
2 parents da8bbda + eef7f2f commit 5a5c0d0
Show file tree
Hide file tree
Showing 154 changed files with 1,306 additions and 117 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
VERSION=$(python3 -c "import pyclasher; print(pyclasher.__version__)")
echo "Package version: $VERSION"
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Upload
- name: Upload to test.pypi.org
run: python3 -m twine upload -u __token__ -p ${{ secrets.TEST_PYPI_TOKEN }} --repository testpypi --skip-existing dist/*
- name: Test
- name: Test of release
run: pip install -i https://test.pypi.org/simple/ pyclasher==$PACKAGE_VERSION
- name: Upload
- name: Upload to pypi.org
run: python3 -m twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} --repository pypi dist/*
34 changes: 27 additions & 7 deletions pyclasher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = (
Expand Down
36 changes: 33 additions & 3 deletions pyclasher/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
from .bulk_requests import *
from .models import *
from .requests import *
from .bulk_requests import PlayerBulkRequest
from .requests import (
BuilderBaseLeagueRequest,
BuilderBaseLeaguesRequest,
CapitalLeagueRequest,
CapitalLeaguesRequest,
CapitalRankingsRequest,
ClanRequest,
ClanBuilderBaseRankingsRequest,
ClanCapitalRaidSeasonsRequest,
ClanCurrentWarRequest,
ClanCurrentwarLeaguegroupRequest,
ClanLabelsRequest,
ClanMembersRequest,
ClanRankingsRequest,
ClanSearchRequest,
ClanWarLogRequest,
ClanWarleaguesWarsRequest,
GoldPassRequest,
LeagueRequest,
LeagueSeasonRequest,
LeagueSeasonsRequest,
LeaguesRequest,
LocationRequest,
LocationsRequest,
PlayerRequest,
PlayerBuilderBaseRankingsRequest,
PlayerLabelsRequest,
PlayerRankingsRequest,
WarLeagueRequest,
WarLeaguesRequest
)


__all__ = (
"PlayerBulkRequest",
Expand Down
1 change: 0 additions & 1 deletion pyclasher/api/bulk_requests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .b_player import PlayerBulkRequest
from .abc import BulkRequestModel

__all__ = (
"PlayerBulkRequest",
Expand Down
13 changes: 11 additions & 2 deletions pyclasher/api/bulk_requests/abc.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from asyncio import gather, get_running_loop, run
from asyncio import gather


__all__ = (
'BulkRequestModel',
)


class BulkRequestModel:
_request_model = ...
_requests = None

def __init__(self):
self._tasks = None

@property
def request_model(self):
return self._request_model
Expand All @@ -29,7 +37,8 @@ def __len__(self):
return len(self._requests)

def __getitem__(self, item):
self._requests[0].to_dict() # test if the `to_dict()` method raises `RequestNotDone`
self._requests[0].to_dict()
# test if the `to_dict()` method raises `RequestNotDone`
if isinstance(item, int):
return self._requests[item]
if isinstance(item, slice):
Expand Down
8 changes: 8 additions & 0 deletions pyclasher/api/bulk_requests/abc.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from typing import Any, Coroutine, Iterator, Generator


__all__ = (
'BulkRequestModel',
)


class BulkRequestModel:
"""
bulk request base model
Expand All @@ -16,6 +21,9 @@ class BulkRequestModel:
_request_model: Any = ...
_requests: list = None

def __init__(self):
self._tasks: list[Coroutine] = ...

@property
def request_model(self) -> Any:
"""
Expand Down
8 changes: 6 additions & 2 deletions pyclasher/api/bulk_requests/b_player.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from asyncio import get_running_loop, run

from .abc import BulkRequestModel
from ..models import BaseClan
from ..models import Clan
from ..requests import PlayerRequest, ClanMembersRequest
from ...exceptions import MISSING


__all__ = (
'PlayerBulkRequest'
)


class PlayerBulkRequest(BulkRequestModel):
_request_model = PlayerRequest

def __init__(self, tags):
super().__init__()
self._tags = tags
self._requests = list(self._request_model(tag) for tag in self.tags)
return
Expand Down
15 changes: 12 additions & 3 deletions pyclasher/api/bulk_requests/b_player.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
from typing import Iterable, Coroutine, Any, Iterator
from typing import Iterable, Iterator

from .abc import BulkRequestModel
from ..models import BaseClan, ClanMemberList, ClanWarMemberList, \
ClanWarLeagueClanMemberList, \
from ..models import (
BaseClan,
ClanMemberList,
ClanWarMemberList,
ClanWarLeagueClanMemberList,
ClanCapitalRaidSeasonMemberList
)
from ..requests import PlayerRequest, ClanMembersRequest


__all__ = (
'PlayerBulkRequest',
)


class PlayerBulkRequest(BulkRequestModel):
"""
class for requesting multiple players at once in parallel
Expand Down
Loading

0 comments on commit 5a5c0d0

Please sign in to comment.