Skip to content

Commit 66b649b

Browse files
committed
Utilise new LeagueWarLogEntry class in get_warlog function
1 parent 4ca113b commit 66b649b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

coc/client.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@
3838

3939
LEAGUE_WAR_STATE = 'notInWar'
4040

41+
4142
def check_json(clss, obj, json_bool):
43+
if isinstance(obj, list):
44+
to_return = []
45+
for n in obj:
46+
to_return.append(check_json(clss, n, json_bool))
47+
return to_return
48+
4249
if isinstance(obj, clss) and json_bool is False:
4350
return obj
4451

@@ -335,7 +342,7 @@ async def get_warlog(self, clan_tag, cache=False, fetch=True, json=False):
335342
336343
Defaults to ``False``.
337344
338-
:return: :class:`WarLog` If ``json=False``, else :class:`dict`
345+
:return: :class:`list` of :class:`WarLog` If ``json=False``, else :class:`dict`
339346
"""
340347
if cache:
341348
data = self._war_logs.get(clan_tag, None)
@@ -346,8 +353,15 @@ async def get_warlog(self, clan_tag, cache=False, fetch=True, json=False):
346353
return None
347354

348355
r = await self.http.get_clan_warlog(clan_tag)
349-
wars = list(WarLog(data=n) for n in r.get('items', []))
350-
self._add_war_log(wars)
356+
357+
wars = []
358+
for n in r.get('items', []):
359+
if n.get('result') is None:
360+
wars.append(LeagueWarLogEntry(data=n))
361+
continue
362+
363+
wars.append(WarLog(data=n))
364+
self._add_war_log(wars)
351365

352366
return wars
353367

0 commit comments

Comments
 (0)