From 2c56bb40ba054ee5000bc7a21d1ed1a1779d1ad1 Mon Sep 17 00:00:00 2001 From: SharpBit <31069084+SharpBit@users.noreply.github.com> Date: Thu, 13 Dec 2018 19:44:21 -0500 Subject: [PATCH] fix leaderboard for the new api changes --- CHANGELOG.md | 3 +++ brawlstats/__init__.py | 2 +- brawlstats/core.py | 11 +++++++---- docs/conf.py | 2 +- setup.py | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b26ec75..67be217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## [2.1.10] - 12/13/18 +- Fix any data that involves a list (Leaderboard) + ## [2.1.9] - 12/11/18 ## Added - `get_datetime` function for easier date and time conversions diff --git a/brawlstats/__init__.py b/brawlstats/__init__.py index c61a121..e816bfb 100644 --- a/brawlstats/__init__.py +++ b/brawlstats/__init__.py @@ -7,7 +7,7 @@ ############ -__version__ = 'v2.1.9' +__version__ = 'v2.1.10' __title__ = 'brawlstats' __license__ = 'MIT' __author__ = 'SharpBit' diff --git a/brawlstats/core.py b/brawlstats/core.py index 7c775c0..3cdf5a4 100644 --- a/brawlstats/core.py +++ b/brawlstats/core.py @@ -41,9 +41,9 @@ def __getattr__(self, attr): def __getitem__(self, item): try: - return getattr(self._boxed_data, item) - except AttributeError: - raise KeyError('No such key: {}'.format(item)) + return self._boxed_data[item] + except IndexError: + raise IndexError('No such index: {}'.format(item)) class Client: @@ -305,7 +305,7 @@ def get_full(self): """ Gets the full club statistics. - Returns club + Returns Club """ return self.client.get_club(self.tag) @@ -327,6 +327,9 @@ class Leaderboard(BaseBox): Returns a player or club leaderboard that contains a list of players or clubs. """ + def __len__(self): + return sum(1 for i in self) + def __repr__(self): return "".format(len(self)) diff --git a/docs/conf.py b/docs/conf.py index 93fe33b..51e1ff7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,7 +26,7 @@ # The short X.Y version version = '2.1' # The full version, including alpha/beta/rc tags -release = '2.1.9' +release = '2.1.10' # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index 14a32bd..1e4ce9a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='brawlstats', - version='2.1.9', + version='2.1.10', description='An async Python API wrapper for the unofficial Brawl Stars API', long_description=long_description, long_description_content_type='text/x-rst',