Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebase before publishing #62

Merged
merged 15 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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