Skip to content

Commit

Permalink
Merge pull request #23 from 201st-Luka/correcting_errors
Browse files Browse the repository at this point in the history
Correcting errors
  • Loading branch information
201st-Luka authored Jul 28, 2023
2 parents a7c0665 + 928843a commit 84ad507
Show file tree
Hide file tree
Showing 47 changed files with 1,504 additions and 549 deletions.
838 changes: 838 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

Binary file added .github/PyClasher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Discord][discord_shield]][discord_url] ![Last commit][last_commit_shield]

# PyClasher
![PyClasher](.github/PyClasher.png)

---
# PyClasher

pyclasher is the name of the asynchronous ClashOfClans API. It is
PyClasher is the name of the asynchronous ClashOfClans API. It is
an object-oriented wrapper client that provides easy access to the
requested data.

Expand All @@ -18,9 +18,16 @@ a python package and will be available for everyone.
If you have any questions, feel free to join my discord server
to ask you question.

## Installation

It is possible to install the package from GitHib releases. You can use the following command to add PyClasher to your library:
```bash
pip install git+https://github.com/201st-Luka/PyClasher.git@v0.0.1-alpha3
```

---

### Features
## Features
- Asynchronous and parallel requesting
- Possibility to use multiple tokens and to login via email address
and password of the ClashOfClans developer portal
Expand All @@ -31,11 +38,34 @@ used tokens

---

### Future
## Contributing

Feel free to contribute to the repository.

You can fork the repository and commit your changes in a pull request. Please consider to check out the
[Discord server][discord_url] if so.

---

## Future

I'm planning to keep the API wrapper up to date and improve it as
good as I can.

### Planned features

- more bulk requests
- pytests for every request
- pytests for the models
- possibility to download files (images, etc) from `api-assets.clashofclans.com`

### Planned utils

- documentation
- real example ([HeadhunterBot][headhunterbot_url] is in development)

---

If you find a bug, an error or want custom functionality, please tell
me via Discord or open an issue or start a discussion on the
GitHub-repository.
Expand All @@ -45,4 +75,5 @@ GitHub-repository.
<!---links--->
[discord_shield]: https://img.shields.io/badge/Discord-blue?logo=discord&logoColor=white
[discord_url]: https://discord.gg/j2PAF9Wru8
[last_commit_shield]: https://img.shields.io/github/last-commit/201st-Luka/HeadhunterBot
[last_commit_shield]: https://img.shields.io/github/last-commit/201st-Luka/HeadhunterBot
[headhunterbot_url]: https://github.com/201st-Luka/HeadhunterBot
3 changes: 2 additions & 1 deletion pyclasher/bulk_requests/BulkPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def tags(self):

@classmethod
async def _async_from_clan(cls, clan):
members = await ClanMembersRequest(clan.tag).request() if isinstance(clan, BaseClan) else await ClanMembersRequest(clan).request()
members = await (ClanMembersRequest(clan.tag).request() if isinstance(clan, BaseClan) else
await ClanMembersRequest(clan).request())
return cls.from_member_list(members)

@classmethod
Expand Down
5 changes: 4 additions & 1 deletion pyclasher/bulk_requests/BulkPlayer.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable, Coroutine, Any
from typing import Iterable, Coroutine, Any, Iterator

from .BulkRequestModel import BulkRequestModel
from ..models import BaseClan, ClanMemberList, ClanWarMemberList, ClanWarLeagueClanMemberList, ClanCapitalRaidSeasonMemberList
Expand Down Expand Up @@ -75,6 +75,9 @@ class PlayerBulkRequest(BulkRequestModel):
"""
...

def __iter__(self) -> Iterator[PlayerRequest]:
...

def __next__(self) -> PlayerRequest:
"""
returns the next player of the bulk request if an iterator is used
Expand Down
3 changes: 2 additions & 1 deletion pyclasher/bulk_requests/BulkRequestModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ def __str__(self):
return f"{self.__class__.__name__}({self._main_attribute})"

def __repr__(self):
return f"{self.__class__.__name__}({', '.join(('='.join((key, str(value))) for key, value in self.__get_properties().items()))})"
return (f"{self.__class__.__name__}"
f"({', '.join(('='.join((key, str(value))) for key, value in self.__get_properties().items()))})")
4 changes: 2 additions & 2 deletions pyclasher/bulk_requests/BulkRequestModel.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Coroutine
from typing import Any, Coroutine, Iterator


class BulkRequestModel:
Expand Down Expand Up @@ -80,7 +80,7 @@ class BulkRequestModel:
def __getitem__(self, item: int) -> _request_model:
...

def __iter__(self):
def __iter__(self) -> Iterator[_request_model]:
self._iter = iter(self._requests)
...

Expand Down
5 changes: 3 additions & 2 deletions pyclasher/models/BaseModels.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
base models for this API wrapper client
"""

from typing import Any
from typing import Any, Iterator

from ..Exceptions import MISSING, Missing

Expand Down Expand Up @@ -126,8 +126,9 @@ class IterBaseModel:
def __getitem__(self, item: int) -> _iter_rtype:
...

def __iter__(self) -> IterBaseModel:
def __iter__(self) -> Iterator[_iter_rtype]:
self._iter = iter(self._data)
...

def __next__(self):
...
Expand Down
4 changes: 4 additions & 0 deletions pyclasher/models/Clan.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
clan models and sub models
"""
from typing import Iterator

from .BaseModels import BaseModel, IterBaseModel, BaseClan
from .ClanMemberList import ClanMemberList
Expand Down Expand Up @@ -60,6 +61,9 @@ class ClanDistrictDataList(IterBaseModel):
def __getitem__(self, item: int) -> ClanDistrictData:
...

def __iter__(self) -> Iterator[ClanDistrictData]:
...

def __next__(self) -> ClanDistrictData:
...

Expand Down
5 changes: 5 additions & 0 deletions pyclasher/models/ClanBuilderBaseRankingList.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

from .BaseModels import BaseModel, IterBaseModel


Expand Down Expand Up @@ -37,5 +39,8 @@ class ClanBuilderBaseRankingList(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanBuilderBaseRanking:
...

def __iter__(self) -> Iterator[ClanBuilderBaseRanking]:
...

def __next__(self) -> ClanBuilderBaseRanking:
...
20 changes: 20 additions & 0 deletions pyclasher/models/ClanCapitalRaidSeasons.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

from .BaseModels import BaseModel, IterBaseModel, BaseClanMember, BaseClan, Time


Expand Down Expand Up @@ -90,6 +92,9 @@ class ClanCapitalRaidSeasonAttackList(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanCapitalRaidSeasonAttack:
...

def __iter__(self) -> Iterator[ClanCapitalRaidSeasonAttack]:
...

def __next__(self) -> ClanCapitalRaidSeasonAttack:
...

Expand Down Expand Up @@ -192,6 +197,9 @@ class ClanCapitalRaidSeasonDistrictList(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanCapitalRaidSeasonDistrict:
...

def __iter__(self) -> Iterator[ClanCapitalRaidSeasonDistrict]:
...

def __next__(self) -> ClanCapitalRaidSeasonDistrict:
...

Expand Down Expand Up @@ -320,6 +328,9 @@ class ClanCapitalRaidSeasonDefenseLogList(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanCapitalRaidSeasonDefenseLogEntry:
...

def __iter__(self) -> Iterator[ClanCapitalRaidSeasonDefenseLogEntry]:
...

def __next__(self) -> ClanCapitalRaidSeasonDefenseLogEntry:
...

Expand All @@ -336,6 +347,9 @@ class ClanCapitalRaidSeasonAttackLogList(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanCapitalRaidSeasonAttackLogEntry:
...

def __iter__(self) -> Iterator[ClanCapitalRaidSeasonAttackLogEntry]:
...

def __next__(self) -> ClanCapitalRaidSeasonAttackLogEntry:
...

Expand Down Expand Up @@ -398,6 +412,9 @@ class ClanCapitalRaidSeasonMemberList(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanCapitalRaidSeasonMember:
...

def __iter__(self) -> Iterator[ClanCapitalRaidSeasonMember]:
...

def __next__(self) -> ClanCapitalRaidSeasonMember:
...

Expand Down Expand Up @@ -531,5 +548,8 @@ class ClanCapitalRaidSeasons(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanCapitalRaidSeason:
...

def __iter__(self) -> Iterator[ClanCapitalRaidSeason]:
...

def __next__(self) -> ClanCapitalRaidSeason:
...
5 changes: 5 additions & 0 deletions pyclasher/models/ClanCapitalRankingList.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

from .BaseModels import BaseModel, IterBaseModel


Expand Down Expand Up @@ -39,5 +41,8 @@ class ClanCapitalRankingList(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanCapitalRanking:
...

def __iter__(self) -> Iterator[ClanCapitalRanking]:
...

def __next__(self) -> ClanCapitalRanking:
...
5 changes: 5 additions & 0 deletions pyclasher/models/ClanList.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

from .BaseModels import IterBaseModel
from .Clan import Clan

Expand All @@ -14,5 +16,8 @@ class ClanList(IterBaseModel):
def __getitem__(self, item: int | str) -> Clan:
...

def __iter__(self) -> Iterator[Clan]:
...

def __next__(self) -> Clan:
...
5 changes: 5 additions & 0 deletions pyclasher/models/ClanMemberList.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

from .BaseModels import IterBaseModel
from .ClanMember import ClanMember

Expand All @@ -16,5 +18,8 @@ class ClanMemberList(IterBaseModel):
def __getitem__(self, item: int | str) -> ClanMember:
...

def __iter__(self) -> Iterator[ClanMember]:
...

def __next__(self) -> ClanMember:
...
9 changes: 7 additions & 2 deletions pyclasher/models/ClanRankingList.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

from .BaseModels import BaseModel, IterBaseModel, BadgeUrls
from .Location import Location

Expand Down Expand Up @@ -106,8 +108,11 @@ class ClanRankingList(IterBaseModel):

_iter_rtype = ClanRanking

def __getitem__(self, item: int | str) -> _iter_rtype:
def __getitem__(self, item: int | str) -> ClanRanking:
...

def __iter__(self) -> Iterator[ClanRanking]:
...

def __next__(self) -> _iter_rtype:
def __next__(self) -> ClanRanking:
...
11 changes: 11 additions & 0 deletions pyclasher/models/ClanWarLeagueGroup.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

from .BaseModels import BaseModel, IterBaseModel, BaseClanMember, BaseClan
from .Enums import ClanWarLeagueGroupState

Expand Down Expand Up @@ -30,6 +32,9 @@ class ClanWarLeagueRoundList(IterBaseModel):
def __getitem__(self, item: int) -> ClanWarLeagueRound:
...

def __iter__(self) -> Iterator[ClanWarLeagueRound]:
...

def __next__(self) -> ClanWarLeagueRound:
...

Expand Down Expand Up @@ -62,6 +67,9 @@ class ClanWarLeagueClanMemberList(IterBaseModel):
def __getitem__(self, item: int) -> ClanWarLeagueClanMember:
...

def __iter__(self) -> Iterator[ClanWarLeagueClanMember]:
...

def __next__(self) -> ClanWarLeagueClanMember:
...

Expand Down Expand Up @@ -104,6 +112,9 @@ class ClanWarLeagueClanList(IterBaseModel):
def __getitem__(self, item: int) -> ClanWarLeagueClan:
...

def __iter__(self) -> Iterator[ClanWarLeagueClan]:
...

def __next__(self) -> ClanWarLeagueClan:
...

Expand Down
5 changes: 5 additions & 0 deletions pyclasher/models/ClanWarLog.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

from .BaseModels import IterBaseModel, BaseModel, Time
from .Enums import ClanWarResult
from .WarClan import WarClan
Expand Down Expand Up @@ -81,5 +83,8 @@ class ClanWarLog(IterBaseModel):
def __getitem__(self, item: int) -> ClanWarLogEntry:
...

def __iter__(self) -> Iterator[ClanWarLogEntry]:
...

def __next__(self) -> ClanWarLogEntry:
...
Loading

0 comments on commit 84ad507

Please sign in to comment.