Skip to content
This repository was archived by the owner on Aug 19, 2018. It is now read-only.

Commit 804dd84

Browse files
committed
fix code
1 parent 1273c25 commit 804dd84

File tree

2 files changed

+11
-33
lines changed

2 files changed

+11
-33
lines changed

crasync/core.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import aiohttp
22
import asyncio
3-
from .models import Profile, Profiles, Clan, Clans, Constants
3+
from .models import Profile, Clan, Constants
44

55

66
class Client:
@@ -20,38 +20,24 @@ def __init__(self, session=None):
2020

2121

2222
async def get_profile(self, *, tags):
23-
'''Get a profile object using tag(s).'''
24-
tags = tags.split(',')
23+
'''Get a profile object using tag(s)'''
2524

26-
if len(tags) == 1:
27-
url = f'{self.BASE}/profile/{tags[0]}'
28-
29-
async with self.session.get(url) as resp:
30-
if resp.status == 200:
31-
data = await resp.json()
32-
else:
33-
print('API is down. Please be patient.')
34-
return None
35-
36-
return Profile(self, data)
25+
tags = ','.join(tags)
3726

38-
taglist = ''
39-
i = 0
40-
for tag in tags:
41-
i += 1
42-
taglist += tag[1:]
43-
if i != len(tags):
44-
taglist += ','
27+
url = f'{self.BASE}/profile/{tags}'
4528

46-
url = f'{self.BASE}/profile/{taglist}'
4729
async with self.session.get(url) as resp:
4830
if resp.status == 200:
4931
data = await resp.json()
5032
else:
5133
raise ConnectionError(f'API not responding: {resp.status}')
52-
return Profiles(self, data)
5334

54-
async def get_clans(self, *, tags):
35+
if isinstance(data, list):
36+
return [Profile(self, c) for c in data]
37+
else:
38+
return Profile(self, data)
39+
40+
async def get_clan(self, *, tags):
5541
'''Get a clan object using tag(s)'''
5642

5743
tags = ','.join(tags)
@@ -67,7 +53,7 @@ async def get_clans(self, *, tags):
6753
if isinstance(data, list):
6854
return [Clan(self, c) for c in data]
6955
else:
70-
return Clan(self, c)
56+
return Clan(self, data)
7157

7258
get_clans = get_clan
7359

crasync/models.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,6 @@ def __repr__(self):
222222
def get_clan(self):
223223
return self.client.get_clan(self.clan_tag)
224224

225-
class Clans(Base):
226-
def from_data(self, data):
227-
self.clans = [Clan(self.client, c) for c in data]
228-
229-
class Profiles(Base):
230-
def from_data(self, data):
231-
self.clans = [Profile(self.client, c) for c in data]
232-
233225
class Constants(Base):
234226
'''Represents the constants from cr-api'''
235227
def from_data(self, data):

0 commit comments

Comments
 (0)