Skip to content

Commit

Permalink
Merge pull request #18 from takos22/1.2.x
Browse files Browse the repository at this point in the history
[RELEASE] v1.2.4
  • Loading branch information
takos22 authored Jun 16, 2022
2 parents 34140e1 + ae07f8b commit 17b62d0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ Changed
- Deprecated `Notification.creation_time <https://codingame.readthedocs.io/en/latest/api.html#codingame.Notification.creation_time>`__ in favor of
`Notification.date <https://codingame.readthedocs.io/en/latest/api.html#codingame.Notification.date>`__

Version 1.2.4 (2022-06-17)
--------------------------

Fixed
*****

- `CodinGamer.get_followers <https://codingame.readthedocs.io/en/latest/api.html#codingame.CodinGamer.get_followers>`__ and `CodinGamer.get_followed <https://codingame.readthedocs.io/en/latest/api.html#codingame.CodinGamer.get_followed>`__ now work
while being logged in as any user, not just as the user you want to get the
followers of.

Version 1.2.3 (2021-11-07)
--------------------------

Expand Down
4 changes: 2 additions & 2 deletions codingame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"VersionInfo", major=int, minor=int, micro=int, releaselevel=str, serial=int
)

version_info = VersionInfo(major=1, minor=2, micro=3, releaselevel="", serial=0)
version_info = VersionInfo(major=1, minor=2, micro=4, releaselevel="", serial=0)

__title__ = "codingame"
__author__ = "takos22"
__version__ = "1.2.3"
__version__ = "1.2.4"

from .clash_of_code import ClashOfCode, Player
from .client import Client
Expand Down
34 changes: 16 additions & 18 deletions codingame/codingamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def get_followers(
Get all the followers of a CodinGamer.
You need to be logged in as the CodinGamer to get its followers
or else a :exc:`LoginRequired` will be raised. If you can't log in,
you can use :meth:`CodinGamer.get_followers_ids` instead.
You need to be logged in to get the followers or else a
:exc:`LoginRequired` will be raised. If you can't log in, you can use
:meth:`CodinGamer.get_followers_ids` instead.
.. note::
This property is a generator.
Expand All @@ -174,25 +174,24 @@ def get_followers(
The follower.
"""

if (
not self._state.logged_in
or self.public_handle != self._state.codingamer.public_handle
):
if not self._state.logged_in:
raise LoginRequired()

if self._state.is_async:

async def _get_followers():
followers = await self._state.http.get_codingamer_followers(
self.id
self.id, self._state.codingamer.id
)
for follower in followers:
yield CodinGamer(self._state, follower)

else:

def _get_followers():
followers = self._state.http.get_codingamer_followers(self.id)
followers = self._state.http.get_codingamer_followers(
self.id, self._state.codingamer.id
)
for follower in followers:
yield CodinGamer(self._state, follower)

Expand Down Expand Up @@ -222,9 +221,9 @@ def get_followed(
Get all the followed CodinGamers.
You need to be logged in as the CodinGamer to get its followed
CodinGamers or else a :exc:`LoginRequired` will be raised. If you can't
log in, you can use :meth:`CodinGamer.get_followed_ids` instead.
You need to be logged in to get the followed CodinGamers or else a
:exc:`LoginRequired` will be raised. If you can't log in, you can use
:meth:`CodinGamer.get_followed_ids` instead.
.. note::
This property is a generator.
Expand All @@ -240,25 +239,24 @@ def get_followed(
The followed CodinGamer.
"""

if (
not self._state.logged_in
or self.public_handle != self._state.codingamer.public_handle
):
if not self._state.logged_in:
raise LoginRequired()

if self._state.is_async:

async def _get_followed():
followeds = await self._state.http.get_codingamer_following(
self.id
self.id, self._state.codingamer.id
)
for followed in followeds:
yield CodinGamer(self._state, followed)

else:

def _get_followed():
followeds = self._state.http.get_codingamer_following(self.id)
followeds = self._state.http.get_codingamer_following(
self.id, self._state.codingamer.id
)
for followed in followeds:
yield CodinGamer(self._state, followed)

Expand Down
16 changes: 12 additions & 4 deletions codingame/http/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,22 @@ def get_codingamer_from_id(self, id: int) -> CodinGamerFromID:
"CodinGamer", "findCodinGamerPublicInformations", [id]
)

def get_codingamer_followers(self, id: int) -> typing.List[Follower]:
return self.request("CodinGamer", "findFollowers", [id, id, None])
def get_codingamer_followers(
self, id: int, current_id: int = None
) -> typing.List[Follower]:
return self.request(
"CodinGamer", "findFollowers", [id, current_id or id, None]
)

def get_codingamer_follower_ids(self, id: int) -> typing.List[int]:
return self.request("CodinGamer", "findFollowerIds", [id])

def get_codingamer_following(self, id: int) -> typing.List[Following]:
return self.request("CodinGamer", "findFollowing", [id, id])
def get_codingamer_following(
self, id: int, current_id: int = None
) -> typing.List[Following]:
return self.request(
"CodinGamer", "findFollowing", [id, current_id or id]
)

def get_codingamer_following_ids(self, id: int) -> typing.List[int]:
return self.request("CodinGamer", "findFollowingIds", [id])
Expand Down
10 changes: 10 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ Changed
- Deprecated :attr:`Notification.creation_time` in favor of
:attr:`Notification.date`

Version 1.2.4 (2022-06-17)
--------------------------

Fixed
*****

- :meth:`CodinGamer.get_followers` and :meth:`CodinGamer.get_followed` now work
while being logged in as any user, not just as the user you want to get the
followers of.

Version 1.2.3 (2021-11-07)
--------------------------

Expand Down

0 comments on commit 17b62d0

Please sign in to comment.