Skip to content

Commit d2e45f5

Browse files
committed
Tidy up code, add changelog and bump version to v0.0.3
1 parent e6c47d6 commit d2e45f5

File tree

8 files changed

+71
-30
lines changed

8 files changed

+71
-30
lines changed

coc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
__version__ = '0.0.1'
3+
__version__ = '0.0.3'
44

55
from .client import Client
66
from .dataclasses import (

coc/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
from .http import HTTPClient
3434
from .dataclasses import *
35-
from .utils import to_json
3635

3736
log = logging.getLogger(__name__)
3837

coc/dataclasses.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"""
2727

2828

29-
import itertools
3029
import pytz
3130

3231

@@ -1190,5 +1189,5 @@ def __init__(self, *, data):
11901189
if self.clan:
11911190
self.attack_count = self.clan._data.get('attacks')
11921191
self.stars = self.clan._data.get('stars')
1193-
self.destruction = self.clan._data.get('destructionPercentag')
1192+
self.destruction = self.clan._data.get('destructionPercentage')
11941193
self.clan_level = self.clan._data.get('clanLevel')

coc/http.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,3 @@ async def get_data_from_url(self, url):
305305
else:
306306
raise HTTPException(r, 'failed to get image')
307307

308-
309-
310-
311-
312-
313-
314-
315-

coc/utils.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,22 @@ def to_json(model):
1414
if isinstance(value, list):
1515
for i in value:
1616
if not isinstance(i, (list, str, bool)):
17-
if attr not in dct.keys():
18-
dct[attr] = [to_json(i)]
19-
else:
20-
dct[attr].append(to_json(i))
17+
dct[attr] = [to_json(i)] if attr not in dct.keys() else dct[attr].append(to_json(i))
2118
continue
22-
if attr not in dct.keys():
23-
dct[attr] = [to_json(i)]
24-
else:
25-
dct[attr].append(to_json(i))
19+
20+
dct[attr] = [to_json(i)] if attr not in dct.keys() else dct[attr].append(to_json(i))
21+
2622
continue
2723

2824
# if it is an object attribute
2925
if not isinstance(value, (list, str, bool)):
30-
if attr not in dct.keys():
31-
dct[attr] = [to_json(value)]
32-
else:
33-
dct[attr].append(to_json(value))
26+
dct[attr] = [to_json(value)] if attr not in dct.keys() else dct[attr].append(to_json(value))
3427
continue
3528

3629
# just a bool, string or int now so can safely add to dict
37-
if attr not in dct.keys():
38-
dct[attr] = [to_json(value)]
39-
else:
40-
dct[attr].append(to_json(value))
30+
dct[attr] = [to_json(value)] if attr not in dct.keys() else dct[attr].append(to_json(value))
4131

42-
return json.dumps(dct, separators=(',', ':'), ensure_ascii=True)
32+
return json.loads(dct, separators=(',', ':'), ensure_ascii=True)
4333

4434

4535

docs/changelog.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.. current-module:: coc
2+
.. _whats_new:
3+
4+
Changelog
5+
===========
6+
This page keeps a fairly detailed, human readable version
7+
of what has changed, and whats new for each version of the lib.
8+
9+
10+
v0.0.3
11+
-------
12+
BugFixes
13+
~~~~~~~~~
14+
- Fix some problems comparing naive and aware timestamps in :class:`.Timestamp`
15+
- Add a private ``_data`` attribute to all data classes.
16+
This is the json as the API returns it. It makes ``json=True`` parameters in
17+
requests easy to handle.
18+
- Only cache complete clan results - ie. `search_clans` only returned a :class:`BasicClan`,
19+
so in order to add some cache consistency, cached clans now only contain :class:`SearchClan`.
20+
21+
Important
22+
----------
23+
- New Class - :class:`.LeagueWarLogEntry` is similar to :class:`WarLog`, however it has it's own
24+
set of attributes to ensure it is easier to use and know which ones are present and not.
25+
- This new class is utilised in ``Client.get_warlog``, which returns a ``list`` of both
26+
``LeagueWarLogEntry`` and ``WarLog``, depending on the war.
27+
28+
Documentation
29+
--------------
30+
- Utilise `sphinx_rtd_theme` for the RTD page
31+
- Add this changelog
32+
- Continue to fix typos and little errors as they are found.
33+
34+
35+
v0.0.2
36+
-------
37+
BugFixes
38+
~~~~~~~~~
39+
- Fix some attributes from inherited classes not being present
40+
- Fix some :exc:`AttributeError` from being thrown due to incomplete data from API
41+
- When a clan is not in war, :class:`.WarClan` will not be present.
42+
Some errors were being thrown due to incomplete data being given from API
43+
- Allow for text-only responses from API (ie. not json)
44+
45+
46+
Important Changes
47+
~~~~~~~~~~~~~~~~~~
48+
- Actually specify that the package coc needs to be installed when installing with pip
49+
- Fix incorrect spelling of both :class:`.Achievement` and :exc:`InvalidArgument`
50+
- Update the examples in the README to work (search_players is not a thing)
51+
52+
53+
v0.0.1
54+
-------
55+
Initial Commit!

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ API Reference
1414

1515
api
1616

17+
Changelog
18+
----------
19+
.. toctree::
20+
:maxdepth: 2
21+
22+
changelog
1723

1824
If you still can't find what you're looking for, try in one of the following pages:
1925

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
with open(os.path.join(os.getcwd(), 'requirements.txt')) as f:
66
requirements = f.read().splitlines()
77

8-
version = '0.0.2'
8+
version = '0.0.3'
99

1010
readme = ''
1111
with open('README.rst') as f:

0 commit comments

Comments
 (0)