body_hash
stringlengths 64
64
| body
stringlengths 23
109k
| docstring
stringlengths 1
57k
| path
stringlengths 4
198
| name
stringlengths 1
115
| repository_name
stringlengths 7
111
| repository_stars
float64 0
191k
| lang
stringclasses 1
value | body_without_docstring
stringlengths 14
108k
| unified
stringlengths 45
133k
|
---|---|---|---|---|---|---|---|---|---|
f8d2d3b649471f8f0be0cdb82c80464a0db641349610379f9c5fb83bb546dffc
|
def clean_tag(tag):
'clean up tag.'
if (tag is None):
return None
t = tag
if t.startswith('#'):
t = t[1:]
t = t.strip()
t = t.upper()
t = t.replace('O', '0')
t = t.replace('B', '8')
return t
|
clean up tag.
|
crprofile/crprofile.py
|
clean_tag
|
zodpixel/SML-Cogs
| 17 |
python
|
def clean_tag(tag):
if (tag is None):
return None
t = tag
if t.startswith('#'):
t = t[1:]
t = t.strip()
t = t.upper()
t = t.replace('O', '0')
t = t.replace('B', '8')
return t
|
def clean_tag(tag):
if (tag is None):
return None
t = tag
if t.startswith('#'):
t = t[1:]
t = t.strip()
t = t.upper()
t = t.replace('O', '0')
t = t.replace('B', '8')
return t<|docstring|>clean up tag.<|endoftext|>
|
3a901b2abf9c3ee1d312b2bc112bc19445f430772cab3714d1173ee289383b22
|
def normalized_card_level(card):
'Card common levels (september update).'
rarity2level = dict(Common=0, Rare=2, Epic=5, Legendary=8)
return (card.get('level', 0) + rarity2level.get(get_card_rarity(card), 0))
|
Card common levels (september update).
|
crprofile/crprofile.py
|
normalized_card_level
|
zodpixel/SML-Cogs
| 17 |
python
|
def normalized_card_level(card):
rarity2level = dict(Common=0, Rare=2, Epic=5, Legendary=8)
return (card.get('level', 0) + rarity2level.get(get_card_rarity(card), 0))
|
def normalized_card_level(card):
rarity2level = dict(Common=0, Rare=2, Epic=5, Legendary=8)
return (card.get('level', 0) + rarity2level.get(get_card_rarity(card), 0))<|docstring|>Card common levels (september update).<|endoftext|>
|
0704585ff1d981405ec77ad545d6242f4991ae21f98f59d84b6af9dcc519ab0a
|
def inline(s, fmt):
'Wrap string with inline escape'
return '`\u200b{}\u200b`'.format(fmt.format(s))
|
Wrap string with inline escape
|
crprofile/crprofile.py
|
inline
|
zodpixel/SML-Cogs
| 17 |
python
|
def inline(s, fmt):
return '`\u200b{}\u200b`'.format(fmt.format(s))
|
def inline(s, fmt):
return '`\u200b{}\u200b`'.format(fmt.format(s))<|docstring|>Wrap string with inline escape<|endoftext|>
|
f9d8b048159c98db20d2467bdf45d07fd78fda250ebf5264548fce7bc321e131
|
def check_folder():
'Check folder.'
if (not os.path.exists(PATH)):
os.makedirs(PATH)
if (not os.path.exists(PATH_PLAYERS)):
os.makedirs(PATH_PLAYERS)
|
Check folder.
|
crprofile/crprofile.py
|
check_folder
|
zodpixel/SML-Cogs
| 17 |
python
|
def check_folder():
if (not os.path.exists(PATH)):
os.makedirs(PATH)
if (not os.path.exists(PATH_PLAYERS)):
os.makedirs(PATH_PLAYERS)
|
def check_folder():
if (not os.path.exists(PATH)):
os.makedirs(PATH)
if (not os.path.exists(PATH_PLAYERS)):
os.makedirs(PATH_PLAYERS)<|docstring|>Check folder.<|endoftext|>
|
d4dcf7e23c576daba3bcd78fa7867f3164b6865246398aef3db5ef84ce522217
|
def check_file():
'Check files.'
if (not dataIO.is_valid_json(JSON)):
dataIO.save_json(JSON, {})
|
Check files.
|
crprofile/crprofile.py
|
check_file
|
zodpixel/SML-Cogs
| 17 |
python
|
def check_file():
if (not dataIO.is_valid_json(JSON)):
dataIO.save_json(JSON, {})
|
def check_file():
if (not dataIO.is_valid_json(JSON)):
dataIO.save_json(JSON, {})<|docstring|>Check files.<|endoftext|>
|
24b863e64bfe1923a03241d844da3e096b9c42c9ecd1f9e603b278500a1e4783
|
def setup(bot):
'Setup bot.'
check_folder()
check_file()
n = CRProfile(bot)
bot.add_cog(n)
|
Setup bot.
|
crprofile/crprofile.py
|
setup
|
zodpixel/SML-Cogs
| 17 |
python
|
def setup(bot):
check_folder()
check_file()
n = CRProfile(bot)
bot.add_cog(n)
|
def setup(bot):
check_folder()
check_file()
n = CRProfile(bot)
bot.add_cog(n)<|docstring|>Setup bot.<|endoftext|>
|
bb6e7f897c823166270850df7b0488c4f8a1806fbd7300705302f46a497e0ab3
|
@staticmethod
def player(tag):
'Return player URL'
return ('https://api.royaleapi.com/player/' + tag.upper())
|
Return player URL
|
crprofile/crprofile.py
|
player
|
zodpixel/SML-Cogs
| 17 |
python
|
@staticmethod
def player(tag):
return ('https://api.royaleapi.com/player/' + tag.upper())
|
@staticmethod
def player(tag):
return ('https://api.royaleapi.com/player/' + tag.upper())<|docstring|>Return player URL<|endoftext|>
|
3d550fbb5960223929326c15cb44fa18a61ccd943b0ecfceac1f9b70f8ec3dda
|
def name(self, name):
'Emoji by name.'
for emoji in self.bot.get_all_emojis():
if (emoji.name == name):
return '<:{}:{}>'.format(emoji.name, emoji.id)
return ''
|
Emoji by name.
|
crprofile/crprofile.py
|
name
|
zodpixel/SML-Cogs
| 17 |
python
|
def name(self, name):
for emoji in self.bot.get_all_emojis():
if (emoji.name == name):
return '<:{}:{}>'.format(emoji.name, emoji.id)
return
|
def name(self, name):
for emoji in self.bot.get_all_emojis():
if (emoji.name == name):
return '<:{}:{}>'.format(emoji.name, emoji.id)
return <|docstring|>Emoji by name.<|endoftext|>
|
f33fd5f42f7d3301edccff4157f7390b71b29a402012fd136285e61676fc0876
|
def key(self, key):
'Chest emojis by api key name or key.\n\n name is used by this cog.\n key is values returned by the api.\n Use key only if name is not set\n '
key = key.lower()
if (key in self.map):
name = self.map[key]
return self.name(name)
return ''
|
Chest emojis by api key name or key.
name is used by this cog.
key is values returned by the api.
Use key only if name is not set
|
crprofile/crprofile.py
|
key
|
zodpixel/SML-Cogs
| 17 |
python
|
def key(self, key):
'Chest emojis by api key name or key.\n\n name is used by this cog.\n key is values returned by the api.\n Use key only if name is not set\n '
key = key.lower()
if (key in self.map):
name = self.map[key]
return self.name(name)
return
|
def key(self, key):
'Chest emojis by api key name or key.\n\n name is used by this cog.\n key is values returned by the api.\n Use key only if name is not set\n '
key = key.lower()
if (key in self.map):
name = self.map[key]
return self.name(name)
return <|docstring|>Chest emojis by api key name or key.
name is used by this cog.
key is values returned by the api.
Use key only if name is not set<|endoftext|>
|
a8a42ceb5272a5f9938e1e231fdb071e754d4cb9c94192c8d4ac69f9e7b3b315
|
def __init__(self, tag: str):
'Init.\n\n Remove # if found.\n Convert to uppercase.\n Convert Os to 0s if found.\n '
if tag.startswith('#'):
tag = tag[1:]
tag = tag.replace('O', '0')
tag = tag.upper()
self._tag = tag
|
Init.
Remove # if found.
Convert to uppercase.
Convert Os to 0s if found.
|
crprofile/crprofile.py
|
__init__
|
zodpixel/SML-Cogs
| 17 |
python
|
def __init__(self, tag: str):
'Init.\n\n Remove # if found.\n Convert to uppercase.\n Convert Os to 0s if found.\n '
if tag.startswith('#'):
tag = tag[1:]
tag = tag.replace('O', '0')
tag = tag.upper()
self._tag = tag
|
def __init__(self, tag: str):
'Init.\n\n Remove # if found.\n Convert to uppercase.\n Convert Os to 0s if found.\n '
if tag.startswith('#'):
tag = tag[1:]
tag = tag.replace('O', '0')
tag = tag.upper()
self._tag = tag<|docstring|>Init.
Remove # if found.
Convert to uppercase.
Convert Os to 0s if found.<|endoftext|>
|
25b2b031e7b51b51bb8e0b6e704fcdc77d1186bc53cfb9b173b2984431b54287
|
@property
def tag(self):
'Return tag as str.'
return self._tag
|
Return tag as str.
|
crprofile/crprofile.py
|
tag
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def tag(self):
return self._tag
|
@property
def tag(self):
return self._tag<|docstring|>Return tag as str.<|endoftext|>
|
173cc4b513a320ce1f47c1da41771d61105fa88a4c36559057f91c662da574d1
|
@property
def valid(self):
'Return true if tag is valid.'
for c in self.tag:
if (c not in self.TAG_CHARACTERS):
return False
return True
|
Return true if tag is valid.
|
crprofile/crprofile.py
|
valid
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def valid(self):
for c in self.tag:
if (c not in self.TAG_CHARACTERS):
return False
return True
|
@property
def valid(self):
for c in self.tag:
if (c not in self.TAG_CHARACTERS):
return False
return True<|docstring|>Return true if tag is valid.<|endoftext|>
|
16e60fc1f108d5583cdee309ca29a96cd15c7a56a31efdda5f14e5a5397d766c
|
@property
def invalid_chars(self):
'Return list of invalid characters.'
invalids = []
for c in self.tag:
if (c not in self.TAG_CHARACTERS):
invalids.append(c)
return invalids
|
Return list of invalid characters.
|
crprofile/crprofile.py
|
invalid_chars
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def invalid_chars(self):
invalids = []
for c in self.tag:
if (c not in self.TAG_CHARACTERS):
invalids.append(c)
return invalids
|
@property
def invalid_chars(self):
invalids = []
for c in self.tag:
if (c not in self.TAG_CHARACTERS):
invalids.append(c)
return invalids<|docstring|>Return list of invalid characters.<|endoftext|>
|
cc25b3e621464bef77d8de6bd9ab3b0e33c02bb2d63a7ebdb1d91eea9fb28a06
|
@property
def invalid_error_msg(self):
'Error message to show if invalid.'
return 'The tag you have entered is not valid. \nList of invalid characters in your tag: {}\nList of valid characters for tags: {}'.format(', '.join(self.invalid_chars), ', '.join(self.TAG_CHARACTERS))
|
Error message to show if invalid.
|
crprofile/crprofile.py
|
invalid_error_msg
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def invalid_error_msg(self):
return 'The tag you have entered is not valid. \nList of invalid characters in your tag: {}\nList of valid characters for tags: {}'.format(', '.join(self.invalid_chars), ', '.join(self.TAG_CHARACTERS))
|
@property
def invalid_error_msg(self):
return 'The tag you have entered is not valid. \nList of invalid characters in your tag: {}\nList of valid characters for tags: {}'.format(', '.join(self.invalid_chars), ', '.join(self.TAG_CHARACTERS))<|docstring|>Error message to show if invalid.<|endoftext|>
|
9c754768fea9b1e79e46f28f7275c3c3f088df9a3421f9a3bcecfa3fcafb9c7c
|
def __init__(self, is_cache=False, data=None, error=False, api_provider=None):
'Init.\n\n Params:\n data: dict from JSON\n is_cache: True is data is cached (flag)\n CHESTS: chest cycle from apk\n '
self.data = data
self.is_cache = is_cache
self.CHESTS = CHESTS
self.error = error
self.info_data = data.get('info')
self.chests_data = data.get('chests')
if (api_provider is None):
self.api_provider = 'cr-api'
else:
self.api_provider = api_provider
|
Init.
Params:
data: dict from JSON
is_cache: True is data is cached (flag)
CHESTS: chest cycle from apk
|
crprofile/crprofile.py
|
__init__
|
zodpixel/SML-Cogs
| 17 |
python
|
def __init__(self, is_cache=False, data=None, error=False, api_provider=None):
'Init.\n\n Params:\n data: dict from JSON\n is_cache: True is data is cached (flag)\n CHESTS: chest cycle from apk\n '
self.data = data
self.is_cache = is_cache
self.CHESTS = CHESTS
self.error = error
self.info_data = data.get('info')
self.chests_data = data.get('chests')
if (api_provider is None):
self.api_provider = 'cr-api'
else:
self.api_provider = api_provider
|
def __init__(self, is_cache=False, data=None, error=False, api_provider=None):
'Init.\n\n Params:\n data: dict from JSON\n is_cache: True is data is cached (flag)\n CHESTS: chest cycle from apk\n '
self.data = data
self.is_cache = is_cache
self.CHESTS = CHESTS
self.error = error
self.info_data = data.get('info')
self.chests_data = data.get('chests')
if (api_provider is None):
self.api_provider = 'cr-api'
else:
self.api_provider = api_provider<|docstring|>Init.
Params:
data: dict from JSON
is_cache: True is data is cached (flag)
CHESTS: chest cycle from apk<|endoftext|>
|
cf8c8d309630a0e4d8cf873a176e59a812c507e7c13186d52cc3a0b5ec52a6c1
|
def prop(self, section, prop, default=0):
'Return sectional attribute.'
attr = self.info_data.get(section)
if (attr is not None):
value = attr.get(prop)
if (value is not None):
return value
return default
|
Return sectional attribute.
|
crprofile/crprofile.py
|
prop
|
zodpixel/SML-Cogs
| 17 |
python
|
def prop(self, section, prop, default=0):
attr = self.info_data.get(section)
if (attr is not None):
value = attr.get(prop)
if (value is not None):
return value
return default
|
def prop(self, section, prop, default=0):
attr = self.info_data.get(section)
if (attr is not None):
value = attr.get(prop)
if (value is not None):
return value
return default<|docstring|>Return sectional attribute.<|endoftext|>
|
fe28fb2cf579645d87f17dd42df9522d2aca518c07ed30e6dce4d6a86f636a3e
|
@property
def tag(self):
'Player tag'
t = self.info_data.get('tag', None)
if (t is None):
return None
t = t.upper()
t = t.replace('#', '')
return t
|
Player tag
|
crprofile/crprofile.py
|
tag
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def tag(self):
t = self.info_data.get('tag', None)
if (t is None):
return None
t = t.upper()
t = t.replace('#', )
return t
|
@property
def tag(self):
t = self.info_data.get('tag', None)
if (t is None):
return None
t = t.upper()
t = t.replace('#', )
return t<|docstring|>Player tag<|endoftext|>
|
9bd780023e2d92c8308d4ccd3d23027b295835381234084cfa808da562bfba7d
|
@property
def name(self):
'IGN.'
return self.info_data.get('name', None)
|
IGN.
|
crprofile/crprofile.py
|
name
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def name(self):
return self.info_data.get('name', None)
|
@property
def name(self):
return self.info_data.get('name', None)<|docstring|>IGN.<|endoftext|>
|
4567888e11add037d8ab5e8f1787b040799a962abf0f2e8fa0bce53f6ca213d6
|
@property
def trophies(self):
'Trophies.'
return self.info_data.get('trophies', None)
|
Trophies.
|
crprofile/crprofile.py
|
trophies
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def trophies(self):
return self.info_data.get('trophies', None)
|
@property
def trophies(self):
return self.info_data.get('trophies', None)<|docstring|>Trophies.<|endoftext|>
|
6df471a79fed4befae2a928c56262f7464e8f00774d1eedad89f41c50668587e
|
@property
def clan(self):
'Clan.'
return self.info_data.get('clan', None)
|
Clan.
|
crprofile/crprofile.py
|
clan
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def clan(self):
return self.info_data.get('clan', None)
|
@property
def clan(self):
return self.info_data.get('clan', None)<|docstring|>Clan.<|endoftext|>
|
c5b4e6c351767b8ffd84a1b2f98abbc175445066f64ed7c1f160b90935560622
|
@property
def not_in_clan(self):
'Not in clan flag.'
return (self.clan is None)
|
Not in clan flag.
|
crprofile/crprofile.py
|
not_in_clan
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def not_in_clan(self):
return (self.clan is None)
|
@property
def not_in_clan(self):
return (self.clan is None)<|docstring|>Not in clan flag.<|endoftext|>
|
ebc62c5fdb21a7f3db33e57b7dfd7be017d85bd483603b434e642a4069a39136
|
@property
def clan_name(self):
'Clan name.'
if self.not_in_clan:
return 'No Clan'
if (self.clan is not None):
return self.clan.get('name', None)
return None
|
Clan name.
|
crprofile/crprofile.py
|
clan_name
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def clan_name(self):
if self.not_in_clan:
return 'No Clan'
if (self.clan is not None):
return self.clan.get('name', None)
return None
|
@property
def clan_name(self):
if self.not_in_clan:
return 'No Clan'
if (self.clan is not None):
return self.clan.get('name', None)
return None<|docstring|>Clan name.<|endoftext|>
|
f6d0d46870360ade41708d01d80803202c0fd4284cf86166a061a066f6f9d2c1
|
@property
def clan_tag(self):
'Clan tag.'
if (self.clan is not None):
t = self.clan.get('tag', None)
t = t.replace('#', '')
return t
return None
|
Clan tag.
|
crprofile/crprofile.py
|
clan_tag
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def clan_tag(self):
if (self.clan is not None):
t = self.clan.get('tag', None)
t = t.replace('#', )
return t
return None
|
@property
def clan_tag(self):
if (self.clan is not None):
t = self.clan.get('tag', None)
t = t.replace('#', )
return t
return None<|docstring|>Clan tag.<|endoftext|>
|
c788b0366f2edb935ed775d07bd968d529a399d099882f6a69de27fa19d5abff
|
@property
def clan_role(self):
'Clan role.'
if self.not_in_clan:
return 'N/A'
if (self.api_provider == 'official'):
return self.info_data.get('role')
if (self.clan is not None):
return self.clan.get('role', None)
return None
|
Clan role.
|
crprofile/crprofile.py
|
clan_role
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def clan_role(self):
if self.not_in_clan:
return 'N/A'
if (self.api_provider == 'official'):
return self.info_data.get('role')
if (self.clan is not None):
return self.clan.get('role', None)
return None
|
@property
def clan_role(self):
if self.not_in_clan:
return 'N/A'
if (self.api_provider == 'official'):
return self.info_data.get('role')
if (self.clan is not None):
return self.clan.get('role', None)
return None<|docstring|>Clan role.<|endoftext|>
|
040f8934e0969d496380ede6c5abe9fff8cd4e916cd40a06f381582c82de56a3
|
@property
def clan_name_tag(self):
'Clan name and tag.'
return '{} #{}'.format(self.clan_name, self.clan_tag)
|
Clan name and tag.
|
crprofile/crprofile.py
|
clan_name_tag
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def clan_name_tag(self):
return '{} #{}'.format(self.clan_name, self.clan_tag)
|
@property
def clan_name_tag(self):
return '{} #{}'.format(self.clan_name, self.clan_tag)<|docstring|>Clan name and tag.<|endoftext|>
|
1b873c4f136eb08bb121b109151fb7a3cc958690f0028f146ebf2488ce0181a0
|
@property
def clan_badge_url(self):
'Clan badge url.'
if self.not_in_clan:
return 'http://smlbiobot.github.io/img/emblems/NoClan.png'
try:
return self.clan['badge']['image']
except KeyError:
pass
return ''
|
Clan badge url.
|
crprofile/crprofile.py
|
clan_badge_url
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def clan_badge_url(self):
if self.not_in_clan:
return 'http://smlbiobot.github.io/img/emblems/NoClan.png'
try:
return self.clan['badge']['image']
except KeyError:
pass
return
|
@property
def clan_badge_url(self):
if self.not_in_clan:
return 'http://smlbiobot.github.io/img/emblems/NoClan.png'
try:
return self.clan['badge']['image']
except KeyError:
pass
return <|docstring|>Clan badge url.<|endoftext|>
|
3601c1187bf800c828dd612c4de0c96a5ac4efb9ad968ec3294e54e25e177b5f
|
@property
def stats(self):
'Stats.'
return self.info_data.get('stats', None)
|
Stats.
|
crprofile/crprofile.py
|
stats
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def stats(self):
return self.info_data.get('stats', None)
|
@property
def stats(self):
return self.info_data.get('stats', None)<|docstring|>Stats.<|endoftext|>
|
90e60d3af1ecb51f12050a57ab873df974ba6b7e6499077da36686798f777a66
|
@property
def challenge_cards_won(self):
'Challenge cards won.'
if (self.api_provider == 'official'):
return self.info_data.get('challengeCardsWon', 0)
return self.prop('stats', 'challengeCardsWon', 0)
|
Challenge cards won.
|
crprofile/crprofile.py
|
challenge_cards_won
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def challenge_cards_won(self):
if (self.api_provider == 'official'):
return self.info_data.get('challengeCardsWon', 0)
return self.prop('stats', 'challengeCardsWon', 0)
|
@property
def challenge_cards_won(self):
if (self.api_provider == 'official'):
return self.info_data.get('challengeCardsWon', 0)
return self.prop('stats', 'challengeCardsWon', 0)<|docstring|>Challenge cards won.<|endoftext|>
|
4c067bdeb95c1fb971fcd2c3d8ac28473d581a1bbac44fedb2da0e57f1721ea9
|
@property
def tourney_cards_won(self):
'Challenge cards won.'
if (self.api_provider == 'official'):
return self.info_data.get('tournamentCardsWon', 0)
return self.prop('stats', 'tournamentCardsWon', 0)
|
Challenge cards won.
|
crprofile/crprofile.py
|
tourney_cards_won
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def tourney_cards_won(self):
if (self.api_provider == 'official'):
return self.info_data.get('tournamentCardsWon', 0)
return self.prop('stats', 'tournamentCardsWon', 0)
|
@property
def tourney_cards_won(self):
if (self.api_provider == 'official'):
return self.info_data.get('tournamentCardsWon', 0)
return self.prop('stats', 'tournamentCardsWon', 0)<|docstring|>Challenge cards won.<|endoftext|>
|
8bf46071bcf463f4f10407ba877e6271a19660365bb46837424a17f1d4a4e5e3
|
@property
def tourney_cards_per_game(self):
'Number of tournament cards won per game played.'
if self.tourney_games:
return (self.tourney_cards_won / self.tourney_games)
return None
|
Number of tournament cards won per game played.
|
crprofile/crprofile.py
|
tourney_cards_per_game
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def tourney_cards_per_game(self):
if self.tourney_games:
return (self.tourney_cards_won / self.tourney_games)
return None
|
@property
def tourney_cards_per_game(self):
if self.tourney_games:
return (self.tourney_cards_won / self.tourney_games)
return None<|docstring|>Number of tournament cards won per game played.<|endoftext|>
|
dd4ffed403eb6662551cc838078c22b5664ac8c1c0717f550ddadf48cc1fa1ab
|
@property
def challenge_max_wins(self):
'Max challenge wins.'
if (self.api_provider == 'official'):
return self.info_data.get('challengeMaxWins', 0)
return self.prop('stats', 'challengeMaxWins', 0)
|
Max challenge wins.
|
crprofile/crprofile.py
|
challenge_max_wins
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def challenge_max_wins(self):
if (self.api_provider == 'official'):
return self.info_data.get('challengeMaxWins', 0)
return self.prop('stats', 'challengeMaxWins', 0)
|
@property
def challenge_max_wins(self):
if (self.api_provider == 'official'):
return self.info_data.get('challengeMaxWins', 0)
return self.prop('stats', 'challengeMaxWins', 0)<|docstring|>Max challenge wins.<|endoftext|>
|
7e48b2952fa8463957995d0f40f1160d726afc8cf9d1519df56b96a3ae0f414d
|
@property
def total_donations(self):
'Total donations.'
if (self.api_provider == 'official'):
return self.info_data.get('totalDonations', 0)
return self.prop('stats', 'totalDonations', 0)
|
Total donations.
|
crprofile/crprofile.py
|
total_donations
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def total_donations(self):
if (self.api_provider == 'official'):
return self.info_data.get('totalDonations', 0)
return self.prop('stats', 'totalDonations', 0)
|
@property
def total_donations(self):
if (self.api_provider == 'official'):
return self.info_data.get('totalDonations', 0)
return self.prop('stats', 'totalDonations', 0)<|docstring|>Total donations.<|endoftext|>
|
dc4b16e8fd9f8cf00fb4a9991a0e0a1b6a9f2a819944775749294fb4115c5a3c
|
@property
def cards_found(self):
'Cards found.'
if (self.api_provider == 'official'):
return len(self.info_data.get('cards'))
return self.prop('stats', 'cardsFound', 0)
|
Cards found.
|
crprofile/crprofile.py
|
cards_found
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def cards_found(self):
if (self.api_provider == 'official'):
return len(self.info_data.get('cards'))
return self.prop('stats', 'cardsFound', 0)
|
@property
def cards_found(self):
if (self.api_provider == 'official'):
return len(self.info_data.get('cards'))
return self.prop('stats', 'cardsFound', 0)<|docstring|>Cards found.<|endoftext|>
|
6e9761f0e6c4e471f7aa8d92cc5ff235a254b9999c6c651d08e0002ac50c730c
|
@property
def favorite_card(self):
'Favorite card.'
if (self.api_provider == 'official'):
card = self.info_data.get('currentFavouriteCard')
card = Constants.get_instance().get_card(name=card.get('name'))
return card
return self.prop('stats', 'favoriteCard', 'soon')
|
Favorite card.
|
crprofile/crprofile.py
|
favorite_card
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def favorite_card(self):
if (self.api_provider == 'official'):
card = self.info_data.get('currentFavouriteCard')
card = Constants.get_instance().get_card(name=card.get('name'))
return card
return self.prop('stats', 'favoriteCard', 'soon')
|
@property
def favorite_card(self):
if (self.api_provider == 'official'):
card = self.info_data.get('currentFavouriteCard')
card = Constants.get_instance().get_card(name=card.get('name'))
return card
return self.prop('stats', 'favoriteCard', 'soon')<|docstring|>Favorite card.<|endoftext|>
|
101ce9a26d7205fb23647ac3ff44d857f1d49b2bdd04ce19cc490581cf884b0c
|
@property
def trophy_current(self):
'Current trophies.'
return self.info_data.get('trophies', 0)
|
Current trophies.
|
crprofile/crprofile.py
|
trophy_current
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def trophy_current(self):
return self.info_data.get('trophies', 0)
|
@property
def trophy_current(self):
return self.info_data.get('trophies', 0)<|docstring|>Current trophies.<|endoftext|>
|
89a74e263c73e3799e7c39fc370d289de223829901de224bd6b514c274fcc0ee
|
@property
def trophy_highest(self):
'Personal best.'
if (self.api_provider == 'official'):
return self.info_data.get('bestTrophies', 0)
return self.prop('stats', 'maxTrophies', 0)
|
Personal best.
|
crprofile/crprofile.py
|
trophy_highest
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def trophy_highest(self):
if (self.api_provider == 'official'):
return self.info_data.get('bestTrophies', 0)
return self.prop('stats', 'maxTrophies', 0)
|
@property
def trophy_highest(self):
if (self.api_provider == 'official'):
return self.info_data.get('bestTrophies', 0)
return self.prop('stats', 'maxTrophies', 0)<|docstring|>Personal best.<|endoftext|>
|
f7ef568234a63c01b8802978df76c7b568638b9de24126dd507b0a32c414cffe
|
@property
def trophy_legendary(self):
'Legendary trophies.'
return self.prop('stats', 'legendaryTrophies', 0)
|
Legendary trophies.
|
crprofile/crprofile.py
|
trophy_legendary
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def trophy_legendary(self):
return self.prop('stats', 'legendaryTrophies', 0)
|
@property
def trophy_legendary(self):
return self.prop('stats', 'legendaryTrophies', 0)<|docstring|>Legendary trophies.<|endoftext|>
|
29969a00152d079d6c82d117700205d643468f151fed1c6e67fb5983674ccddf
|
def trophy_value(self, emoji):
'Trophy values.\n\n Current / Highest (PB)\n '
return '{} / {} PB {}'.format('{:,}'.format(self.trophy_current), '{:,}'.format(self.trophy_highest), emoji)
|
Trophy values.
Current / Highest (PB)
|
crprofile/crprofile.py
|
trophy_value
|
zodpixel/SML-Cogs
| 17 |
python
|
def trophy_value(self, emoji):
'Trophy values.\n\n Current / Highest (PB)\n '
return '{} / {} PB {}'.format('{:,}'.format(self.trophy_current), '{:,}'.format(self.trophy_highest), emoji)
|
def trophy_value(self, emoji):
'Trophy values.\n\n Current / Highest (PB)\n '
return '{} / {} PB {}'.format('{:,}'.format(self.trophy_current), '{:,}'.format(self.trophy_highest), emoji)<|docstring|>Trophy values.
Current / Highest (PB)<|endoftext|>
|
feefd06cdf18ee8850fb1a85a2d575da4b2f28c0444cc1557e4e312cb9c82ad3
|
@property
def level(self):
'XP Level.'
if (self.api_provider == 'official'):
return self.info_data.get('expLevel')
return self.prop('stats', 'level', 0)
|
XP Level.
|
crprofile/crprofile.py
|
level
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def level(self):
if (self.api_provider == 'official'):
return self.info_data.get('expLevel')
return self.prop('stats', 'level', 0)
|
@property
def level(self):
if (self.api_provider == 'official'):
return self.info_data.get('expLevel')
return self.prop('stats', 'level', 0)<|docstring|>XP Level.<|endoftext|>
|
6e0ca665f6d6ee6c09e7bd1e03e3ecf39e6cc4dbecb9e13ca302de29c0322fbc
|
@property
def games(self):
'Game stats.'
return self.info_data.get('games')
|
Game stats.
|
crprofile/crprofile.py
|
games
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def games(self):
return self.info_data.get('games')
|
@property
def games(self):
return self.info_data.get('games')<|docstring|>Game stats.<|endoftext|>
|
de3d3cc8470816584cccb288e785613fd4f036c53e1253ca6e37cc279507f2c0
|
@property
def tourney_games(self):
'Number of tournament games.'
if (self.api_provider == 'official'):
return self.info_data.get('tournamentBattleCount', 0)
return self.prop('games', 'tournamentGames', 0)
|
Number of tournament games.
|
crprofile/crprofile.py
|
tourney_games
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def tourney_games(self):
if (self.api_provider == 'official'):
return self.info_data.get('tournamentBattleCount', 0)
return self.prop('games', 'tournamentGames', 0)
|
@property
def tourney_games(self):
if (self.api_provider == 'official'):
return self.info_data.get('tournamentBattleCount', 0)
return self.prop('games', 'tournamentGames', 0)<|docstring|>Number of tournament games.<|endoftext|>
|
fa49609414ac1bac64e008caa1dbd5de5f04f5d6f6665876dd2ed096496651f8
|
@property
def wins(self):
'Games won.'
if (self.api_provider == 'official'):
return self.info_data.get('wins', 0)
return self.prop('games', 'wins', 0)
|
Games won.
|
crprofile/crprofile.py
|
wins
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def wins(self):
if (self.api_provider == 'official'):
return self.info_data.get('wins', 0)
return self.prop('games', 'wins', 0)
|
@property
def wins(self):
if (self.api_provider == 'official'):
return self.info_data.get('wins', 0)
return self.prop('games', 'wins', 0)<|docstring|>Games won.<|endoftext|>
|
4fc51462ddd21fdb24c43fec7151109300a78dc8ca68ca76951b385f3073d369
|
@property
def losses(self):
'Games won.'
if (self.api_provider == 'official'):
return self.info_data.get('losses', 0)
return self.prop('games', 'losses', 0)
|
Games won.
|
crprofile/crprofile.py
|
losses
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def losses(self):
if (self.api_provider == 'official'):
return self.info_data.get('losses', 0)
return self.prop('games', 'losses', 0)
|
@property
def losses(self):
if (self.api_provider == 'official'):
return self.info_data.get('losses', 0)
return self.prop('games', 'losses', 0)<|docstring|>Games won.<|endoftext|>
|
69a4bbd3f2b3519e90651c1b6ada87ea34a91c26dd00fc4ab4ea555a44b7ca29
|
@property
def draws(self):
'Games won.'
return self.prop('games', 'draws', 0)
|
Games won.
|
crprofile/crprofile.py
|
draws
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def draws(self):
return self.prop('games', 'draws', 0)
|
@property
def draws(self):
return self.prop('games', 'draws', 0)<|docstring|>Games won.<|endoftext|>
|
0d8e3cf083f51e752a48e2e8a847d0d0159e1676144fa47b6183fb147daed03e
|
def win_losses(self, emoji):
'Win / losses.'
return '{} / {} {}'.format('{:,}'.format(self.wins), '{:,}'.format(self.losses), emoji)
|
Win / losses.
|
crprofile/crprofile.py
|
win_losses
|
zodpixel/SML-Cogs
| 17 |
python
|
def win_losses(self, emoji):
return '{} / {} {}'.format('{:,}'.format(self.wins), '{:,}'.format(self.losses), emoji)
|
def win_losses(self, emoji):
return '{} / {} {}'.format('{:,}'.format(self.wins), '{:,}'.format(self.losses), emoji)<|docstring|>Win / losses.<|endoftext|>
|
55aab71b0fc0cfadb8200f76ea816246a9ef7923bc77c03f93495385b41cfb70
|
@property
def total_games(self):
'Total games played.'
if (self.api_provider == 'official'):
return self.info_data.get('battleCount', 0)
return self.prop('games', 'total', 0)
|
Total games played.
|
crprofile/crprofile.py
|
total_games
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def total_games(self):
if (self.api_provider == 'official'):
return self.info_data.get('battleCount', 0)
return self.prop('games', 'total', 0)
|
@property
def total_games(self):
if (self.api_provider == 'official'):
return self.info_data.get('battleCount', 0)
return self.prop('games', 'total', 0)<|docstring|>Total games played.<|endoftext|>
|
64992a8ad25a04ecf6e6181f91b41a598115bec7416df1f116f0aaf0f87ae70c
|
@property
def win_streak(self):
'Win streak.'
return max(self.prop('games', 'currentWinStreak', 0), 0)
|
Win streak.
|
crprofile/crprofile.py
|
win_streak
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def win_streak(self):
return max(self.prop('games', 'currentWinStreak', 0), 0)
|
@property
def win_streak(self):
return max(self.prop('games', 'currentWinStreak', 0), 0)<|docstring|>Win streak.<|endoftext|>
|
3b11efa87f814661f8d2e772154173e92ee4cbb6c0aab6dc9734bc08afcd6678
|
@property
def three_crown_wins(self):
'Three crown wins.'
if (self.api_provider == 'official'):
return self.info_data.get('threeCrownWins')
return self.prop('stats', 'threeCrownWins', 0)
|
Three crown wins.
|
crprofile/crprofile.py
|
three_crown_wins
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def three_crown_wins(self):
if (self.api_provider == 'official'):
return self.info_data.get('threeCrownWins')
return self.prop('stats', 'threeCrownWins', 0)
|
@property
def three_crown_wins(self):
if (self.api_provider == 'official'):
return self.info_data.get('threeCrownWins')
return self.prop('stats', 'threeCrownWins', 0)<|docstring|>Three crown wins.<|endoftext|>
|
202d8d0d31edb2d3230557aacc9c8678f2003275535ec81af2efb26be68c0c70
|
@property
def rank(self):
'Global rank'
return self.current_season_rank
|
Global rank
|
crprofile/crprofile.py
|
rank
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def rank(self):
return self.current_season_rank
|
@property
def rank(self):
return self.current_season_rank<|docstring|>Global rank<|endoftext|>
|
7add37d0ee0611077e0318d9c228ad09606103fa46e12e31aafbecc628d4cc3d
|
def rank_ord_str(rank):
'Rank in ordinal format.'
if (rank is not None):
p = inflect.engine()
o = p.ordinal(rank)[(- 2):]
return '{:,}{}'.format(rank, o)
return 'Unranked'
|
Rank in ordinal format.
|
crprofile/crprofile.py
|
rank_ord_str
|
zodpixel/SML-Cogs
| 17 |
python
|
def rank_ord_str(rank):
if (rank is not None):
p = inflect.engine()
o = p.ordinal(rank)[(- 2):]
return '{:,}{}'.format(rank, o)
return 'Unranked'
|
def rank_ord_str(rank):
if (rank is not None):
p = inflect.engine()
o = p.ordinal(rank)[(- 2):]
return '{:,}{}'.format(rank, o)
return 'Unranked'<|docstring|>Rank in ordinal format.<|endoftext|>
|
25609a3156d9bc206c6a6f21bd0cf68f7d1b7ec355a47404fafa58b8b9805b3e
|
@property
def rank_ord(self):
'Rank in ordinal format.'
return self.rank_ord_str(self.rank)
|
Rank in ordinal format.
|
crprofile/crprofile.py
|
rank_ord
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def rank_ord(self):
return self.rank_ord_str(self.rank)
|
@property
def rank_ord(self):
return self.rank_ord_str(self.rank)<|docstring|>Rank in ordinal format.<|endoftext|>
|
c2ec977af379099ec54e5d162fe3f4506fa0d69691092022666c257a28f61dd2
|
def rank_str(self, bot_emoji: BotEmoji):
'Rank in ordinal format.'
if (self.rank is None):
return 'Unranked'
p = inflect.engine()
o = p.ordinal(self.rank)[(- 2):]
return '{:,}{} {}'.format(self.rank, o, bot_emoji.name('rank'))
|
Rank in ordinal format.
|
crprofile/crprofile.py
|
rank_str
|
zodpixel/SML-Cogs
| 17 |
python
|
def rank_str(self, bot_emoji: BotEmoji):
if (self.rank is None):
return 'Unranked'
p = inflect.engine()
o = p.ordinal(self.rank)[(- 2):]
return '{:,}{} {}'.format(self.rank, o, bot_emoji.name('rank'))
|
def rank_str(self, bot_emoji: BotEmoji):
if (self.rank is None):
return 'Unranked'
p = inflect.engine()
o = p.ordinal(self.rank)[(- 2):]
return '{:,}{} {}'.format(self.rank, o, bot_emoji.name('rank'))<|docstring|>Rank in ordinal format.<|endoftext|>
|
2aa215fb2105a356ccea63cd1d8349587d07a03ed93b0a278d28977cef0c9a73
|
def chest_list(self, bot_emoji: BotEmoji):
'List of chests.'
chest_cycle = self.chests_data
if (chest_cycle is None):
return ''
if (self.api_provider == 'official'):
out = []
for c in chest_cycle.get('items'):
out.append(bot_emoji.key(c.get('name', '').lower()))
out.append(str((c.get('index', 0) + 1)))
return ' '.join(out)
else:
upcoming = chest_cycle.get('upcoming')
special_chests = [(k, v) for (k, v) in chest_cycle.items() if (k != 'upcoming')]
special_chests = sorted(special_chests, key=(lambda x: x[1]))
out = []
if (upcoming is not None):
for c in upcoming:
out.append(bot_emoji.key(c.lower()))
for (k, v) in special_chests:
out.append((bot_emoji.key(k) + str((v + 1))))
return ''.join(out)
|
List of chests.
|
crprofile/crprofile.py
|
chest_list
|
zodpixel/SML-Cogs
| 17 |
python
|
def chest_list(self, bot_emoji: BotEmoji):
chest_cycle = self.chests_data
if (chest_cycle is None):
return
if (self.api_provider == 'official'):
out = []
for c in chest_cycle.get('items'):
out.append(bot_emoji.key(c.get('name', ).lower()))
out.append(str((c.get('index', 0) + 1)))
return ' '.join(out)
else:
upcoming = chest_cycle.get('upcoming')
special_chests = [(k, v) for (k, v) in chest_cycle.items() if (k != 'upcoming')]
special_chests = sorted(special_chests, key=(lambda x: x[1]))
out = []
if (upcoming is not None):
for c in upcoming:
out.append(bot_emoji.key(c.lower()))
for (k, v) in special_chests:
out.append((bot_emoji.key(k) + str((v + 1))))
return .join(out)
|
def chest_list(self, bot_emoji: BotEmoji):
chest_cycle = self.chests_data
if (chest_cycle is None):
return
if (self.api_provider == 'official'):
out = []
for c in chest_cycle.get('items'):
out.append(bot_emoji.key(c.get('name', ).lower()))
out.append(str((c.get('index', 0) + 1)))
return ' '.join(out)
else:
upcoming = chest_cycle.get('upcoming')
special_chests = [(k, v) for (k, v) in chest_cycle.items() if (k != 'upcoming')]
special_chests = sorted(special_chests, key=(lambda x: x[1]))
out = []
if (upcoming is not None):
for c in upcoming:
out.append(bot_emoji.key(c.lower()))
for (k, v) in special_chests:
out.append((bot_emoji.key(k) + str((v + 1))))
return .join(out)<|docstring|>List of chests.<|endoftext|>
|
804cbb84931f84550bfb3197f3e49f3d166a0b123eb933dbc0cb07a59fc96629
|
@property
def win_ratio(self):
'Win ratio.\n\n Draws reported by API includes 2v2, so we remove those data\n '
return (self.wins / (self.wins + self.losses))
|
Win ratio.
Draws reported by API includes 2v2, so we remove those data
|
crprofile/crprofile.py
|
win_ratio
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def win_ratio(self):
'Win ratio.\n\n Draws reported by API includes 2v2, so we remove those data\n '
return (self.wins / (self.wins + self.losses))
|
@property
def win_ratio(self):
'Win ratio.\n\n Draws reported by API includes 2v2, so we remove those data\n '
return (self.wins / (self.wins + self.losses))<|docstring|>Win ratio.
Draws reported by API includes 2v2, so we remove those data<|endoftext|>
|
f322a2d06d8a1bc60a1b9f846641089e4533ac01259f9c059559249066874724
|
@property
def arena(self):
'League. Can be either Arena or league.'
o = None
if (self.api_provider == 'official'):
a_id = self.info_data.get('arena', {}).get('id')
if a_id:
o = Constants.get_instance().get_arena(id=a_id)
else:
try:
o = self.info_data.get('arena', {}).get('arena')
except KeyError:
pass
return o
|
League. Can be either Arena or league.
|
crprofile/crprofile.py
|
arena
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def arena(self):
o = None
if (self.api_provider == 'official'):
a_id = self.info_data.get('arena', {}).get('id')
if a_id:
o = Constants.get_instance().get_arena(id=a_id)
else:
try:
o = self.info_data.get('arena', {}).get('arena')
except KeyError:
pass
return o
|
@property
def arena(self):
o = None
if (self.api_provider == 'official'):
a_id = self.info_data.get('arena', {}).get('id')
if a_id:
o = Constants.get_instance().get_arena(id=a_id)
else:
try:
o = self.info_data.get('arena', {}).get('arena')
except KeyError:
pass
return o<|docstring|>League. Can be either Arena or league.<|endoftext|>
|
5ced4e581ff1562ed236d46f4d7b6d8b3ad7d2437007692a1089f99a482f7005
|
@property
def arena_text(self):
'Arena text.'
if (self.api_provider == 'official'):
return self.arena.get('title')
try:
return self.info_data.get('arena', {}).get('name')
except KeyError:
return None
|
Arena text.
|
crprofile/crprofile.py
|
arena_text
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def arena_text(self):
if (self.api_provider == 'official'):
return self.arena.get('title')
try:
return self.info_data.get('arena', {}).get('name')
except KeyError:
return None
|
@property
def arena_text(self):
if (self.api_provider == 'official'):
return self.arena.get('title')
try:
return self.info_data.get('arena', {}).get('name')
except KeyError:
return None<|docstring|>Arena text.<|endoftext|>
|
3ca3d16c4dd623682e3106a69a07de38e3470bd9cb58c35a87687c8785fc6447
|
@property
def arena_subtitle(self):
'Arena subtitle'
if (self.api_provider == 'official'):
return self.arena.get('subtitle')
try:
return self.info_data.get('arena', {}).get('arena')
except KeyError:
return None
|
Arena subtitle
|
crprofile/crprofile.py
|
arena_subtitle
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def arena_subtitle(self):
if (self.api_provider == 'official'):
return self.arena.get('subtitle')
try:
return self.info_data.get('arena', {}).get('arena')
except KeyError:
return None
|
@property
def arena_subtitle(self):
if (self.api_provider == 'official'):
return self.arena.get('subtitle')
try:
return self.info_data.get('arena', {}).get('arena')
except KeyError:
return None<|docstring|>Arena subtitle<|endoftext|>
|
b3abb853e5e6465c5f6487e43648b2ff73c8a70d0c87a07f963de285260dabb5
|
@property
def arena_id(self):
'Arena ID.'
if (self.api_provider == 'official'):
return self.arena.get('arena_id')
else:
return self.info_data.get('arena', {}).get('arenaID')
|
Arena ID.
|
crprofile/crprofile.py
|
arena_id
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def arena_id(self):
if (self.api_provider == 'official'):
return self.arena.get('arena_id')
else:
return self.info_data.get('arena', {}).get('arenaID')
|
@property
def arena_id(self):
if (self.api_provider == 'official'):
return self.arena.get('arena_id')
else:
return self.info_data.get('arena', {}).get('arenaID')<|docstring|>Arena ID.<|endoftext|>
|
f1e8675da73477ac9b2c8575ddd5441405ddc219a3ce18a821c1c36c88d71ccb
|
@property
def league(self):
'League (int).'
league = max((self.arena_id - 12), 0)
return league
|
League (int).
|
crprofile/crprofile.py
|
league
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def league(self):
league = max((self.arena_id - 12), 0)
return league
|
@property
def league(self):
league = max((self.arena_id - 12), 0)
return league<|docstring|>League (int).<|endoftext|>
|
20aaa6eaf1b92fa42884d81ec302e9a093cd048c9b0ca36a57ad1b1cc3d25f24
|
def fave_card(self, bot_emoji: BotEmoji):
'Favorite card in emoji and name.'
emoji = bot_emoji.name(self.favorite_card['key'].replace('-', ''))
return '{} {}'.format(self.favorite_card['name'], emoji)
|
Favorite card in emoji and name.
|
crprofile/crprofile.py
|
fave_card
|
zodpixel/SML-Cogs
| 17 |
python
|
def fave_card(self, bot_emoji: BotEmoji):
emoji = bot_emoji.name(self.favorite_card['key'].replace('-', ))
return '{} {}'.format(self.favorite_card['name'], emoji)
|
def fave_card(self, bot_emoji: BotEmoji):
emoji = bot_emoji.name(self.favorite_card['key'].replace('-', ))
return '{} {}'.format(self.favorite_card['name'], emoji)<|docstring|>Favorite card in emoji and name.<|endoftext|>
|
965f3f5c20c2f035cd8092def450cbca8857bbd3eba0a860125d5d4de4e9dca4
|
@property
def arena_url(self):
'Arena Icon URL.'
if (self.api_provider == 'official'):
url = 'https://royaleapi.github.io/cr-api-assets/arenas/arena{}.png?3'.format(self.arena_arena)
elif (self.league > 0):
url = 'https://royaleapi.github.io/cr-api-assets/arenas/league{}.png?3'.format(self.league)
else:
url = 'https://royaleapi.github.io/cr-api-assets/arenas/arena{}.png?3'.format(self.arena.Arena)
return url
|
Arena Icon URL.
|
crprofile/crprofile.py
|
arena_url
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def arena_url(self):
if (self.api_provider == 'official'):
url = 'https://royaleapi.github.io/cr-api-assets/arenas/arena{}.png?3'.format(self.arena_arena)
elif (self.league > 0):
url = 'https://royaleapi.github.io/cr-api-assets/arenas/league{}.png?3'.format(self.league)
else:
url = 'https://royaleapi.github.io/cr-api-assets/arenas/arena{}.png?3'.format(self.arena.Arena)
return url
|
@property
def arena_url(self):
if (self.api_provider == 'official'):
url = 'https://royaleapi.github.io/cr-api-assets/arenas/arena{}.png?3'.format(self.arena_arena)
elif (self.league > 0):
url = 'https://royaleapi.github.io/cr-api-assets/arenas/league{}.png?3'.format(self.league)
else:
url = 'https://royaleapi.github.io/cr-api-assets/arenas/arena{}.png?3'.format(self.arena.Arena)
return url<|docstring|>Arena Icon URL.<|endoftext|>
|
c6570faf39bbf3961a2f775ae41a7e36471c683b5b821f99d45aa55e5eca0eef
|
def deck_list(self, bot_emoji: BotEmoji):
'Deck with emoji'
o = ' '
cards = self.deck_card_keys
if cards:
cards = [bot_emoji.name(key.replace('-', '')) for key in cards]
levels = [normalized_card_level(card) for card in self.info_data.get('currentDeck')]
deck = ['{0[0]}{0[1]}'.format(card) for card in zip(cards, levels)]
o = ' '.join(deck)
return o
|
Deck with emoji
|
crprofile/crprofile.py
|
deck_list
|
zodpixel/SML-Cogs
| 17 |
python
|
def deck_list(self, bot_emoji: BotEmoji):
o = ' '
cards = self.deck_card_keys
if cards:
cards = [bot_emoji.name(key.replace('-', )) for key in cards]
levels = [normalized_card_level(card) for card in self.info_data.get('currentDeck')]
deck = ['{0[0]}{0[1]}'.format(card) for card in zip(cards, levels)]
o = ' '.join(deck)
return o
|
def deck_list(self, bot_emoji: BotEmoji):
o = ' '
cards = self.deck_card_keys
if cards:
cards = [bot_emoji.name(key.replace('-', )) for key in cards]
levels = [normalized_card_level(card) for card in self.info_data.get('currentDeck')]
deck = ['{0[0]}{0[1]}'.format(card) for card in zip(cards, levels)]
o = ' '.join(deck)
return o<|docstring|>Deck with emoji<|endoftext|>
|
6a3908388cc31e47f16df85797bb677e7b58e5de5bd9cf7d5f970d0ca4e4f77a
|
def trade_list(self, bot_emoji: BotEmoji):
'Trade list'
d = dict(Legendary=1, Epic=10, Rare=50, Common=250)
cards = dict(Legendary=[], Epic=[], Rare=[], Common=[])
for card in self.cards:
for rarity in d.keys():
limit = d.get(card.get('rarity'), 0)
if (card.get('rarity') == rarity):
if limit:
trade_count = math.floor((card.get('count', 0) / limit))
if (card.get('level') == 1):
trade_count -= 1
if (trade_count > 0):
cards[rarity].append(dict(emoji=bot_emoji.name(card.get('key').replace('-', '')), count='x{}'.format(trade_count)))
if (card.get('level') == card.get('maxLevel')):
cards[rarity].append(dict(emoji=bot_emoji.name(card.get('key').replace('-', '')), count='M'))
ret = {}
groups = {}
for (k, v) in cards.items():
groups[k] = 0
for (k, v) in cards.items():
groups = grouper(5, v)
ret[k] = []
for group in groups:
ret[k].extend(['{0[emoji]}{0[count]}'.format(card) for card in group if (card is not None)])
return ret
|
Trade list
|
crprofile/crprofile.py
|
trade_list
|
zodpixel/SML-Cogs
| 17 |
python
|
def trade_list(self, bot_emoji: BotEmoji):
d = dict(Legendary=1, Epic=10, Rare=50, Common=250)
cards = dict(Legendary=[], Epic=[], Rare=[], Common=[])
for card in self.cards:
for rarity in d.keys():
limit = d.get(card.get('rarity'), 0)
if (card.get('rarity') == rarity):
if limit:
trade_count = math.floor((card.get('count', 0) / limit))
if (card.get('level') == 1):
trade_count -= 1
if (trade_count > 0):
cards[rarity].append(dict(emoji=bot_emoji.name(card.get('key').replace('-', )), count='x{}'.format(trade_count)))
if (card.get('level') == card.get('maxLevel')):
cards[rarity].append(dict(emoji=bot_emoji.name(card.get('key').replace('-', )), count='M'))
ret = {}
groups = {}
for (k, v) in cards.items():
groups[k] = 0
for (k, v) in cards.items():
groups = grouper(5, v)
ret[k] = []
for group in groups:
ret[k].extend(['{0[emoji]}{0[count]}'.format(card) for card in group if (card is not None)])
return ret
|
def trade_list(self, bot_emoji: BotEmoji):
d = dict(Legendary=1, Epic=10, Rare=50, Common=250)
cards = dict(Legendary=[], Epic=[], Rare=[], Common=[])
for card in self.cards:
for rarity in d.keys():
limit = d.get(card.get('rarity'), 0)
if (card.get('rarity') == rarity):
if limit:
trade_count = math.floor((card.get('count', 0) / limit))
if (card.get('level') == 1):
trade_count -= 1
if (trade_count > 0):
cards[rarity].append(dict(emoji=bot_emoji.name(card.get('key').replace('-', )), count='x{}'.format(trade_count)))
if (card.get('level') == card.get('maxLevel')):
cards[rarity].append(dict(emoji=bot_emoji.name(card.get('key').replace('-', )), count='M'))
ret = {}
groups = {}
for (k, v) in cards.items():
groups[k] = 0
for (k, v) in cards.items():
groups = grouper(5, v)
ret[k] = []
for group in groups:
ret[k].extend(['{0[emoji]}{0[count]}'.format(card) for card in group if (card is not None)])
return ret<|docstring|>Trade list<|endoftext|>
|
7d59dd0d3093a8249bab3eae6b83292bbc6c47d5294f4a80c79fcae00b16f024
|
def api_cardname_to_emoji(self, name, bot_emoji: BotEmoji):
'Convert api card id to card emoji.'
cr = dataIO.load_json(os.path.join(PATH, 'clashroyale.json'))
cards = cr['Cards']
result = None
for (crid, o) in cards.items():
if (o['sfid'] == name):
result = crid
break
if (result is None):
return None
result = result.replace('-', '')
return bot_emoji.name(result)
|
Convert api card id to card emoji.
|
crprofile/crprofile.py
|
api_cardname_to_emoji
|
zodpixel/SML-Cogs
| 17 |
python
|
def api_cardname_to_emoji(self, name, bot_emoji: BotEmoji):
cr = dataIO.load_json(os.path.join(PATH, 'clashroyale.json'))
cards = cr['Cards']
result = None
for (crid, o) in cards.items():
if (o['sfid'] == name):
result = crid
break
if (result is None):
return None
result = result.replace('-', )
return bot_emoji.name(result)
|
def api_cardname_to_emoji(self, name, bot_emoji: BotEmoji):
cr = dataIO.load_json(os.path.join(PATH, 'clashroyale.json'))
cards = cr['Cards']
result = None
for (crid, o) in cards.items():
if (o['sfid'] == name):
result = crid
break
if (result is None):
return None
result = result.replace('-', )
return bot_emoji.name(result)<|docstring|>Convert api card id to card emoji.<|endoftext|>
|
7f49f1e8a7a90d2620ca3405c807ba10ad87edcc4d170fe1435b70b8a626d29f
|
@property
def seasons(self):
'Season finishes.'
s_list = []
for s in self.info_data.get('previousSeasons'):
s_list.append({'number': s.get('seasonNumber', None), 'highest': s.get('seasonHighest', None), 'ending': s.get('seasonEnding', None), 'rank': s.get('seasonEndGlobalRank', None)})
s_list = sorted(s_list, key=(lambda s: s['number']))
return s_list
|
Season finishes.
|
crprofile/crprofile.py
|
seasons
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def seasons(self):
s_list = []
for s in self.info_data.get('previousSeasons'):
s_list.append({'number': s.get('seasonNumber', None), 'highest': s.get('seasonHighest', None), 'ending': s.get('seasonEnding', None), 'rank': s.get('seasonEndGlobalRank', None)})
s_list = sorted(s_list, key=(lambda s: s['number']))
return s_list
|
@property
def seasons(self):
s_list = []
for s in self.info_data.get('previousSeasons'):
s_list.append({'number': s.get('seasonNumber', None), 'highest': s.get('seasonHighest', None), 'ending': s.get('seasonEnding', None), 'rank': s.get('seasonEndGlobalRank', None)})
s_list = sorted(s_list, key=(lambda s: s['number']))
return s_list<|docstring|>Season finishes.<|endoftext|>
|
dea45295291fdf57308b23a7733984ca3e3328c69dca1ff62159e3e721bdfff4
|
@property
def cards(self):
'Card collection.'
if (self.api_provider == 'official'):
cards_data = self.info_data.get('cards', [])
for c in cards_data:
c.update(Constants.get_instance().get_card(name=c.get('name')))
return cards_data
return self.info_data.get('cards')
|
Card collection.
|
crprofile/crprofile.py
|
cards
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def cards(self):
if (self.api_provider == 'official'):
cards_data = self.info_data.get('cards', [])
for c in cards_data:
c.update(Constants.get_instance().get_card(name=c.get('name')))
return cards_data
return self.info_data.get('cards')
|
@property
def cards(self):
if (self.api_provider == 'official'):
cards_data = self.info_data.get('cards', [])
for c in cards_data:
c.update(Constants.get_instance().get_card(name=c.get('name')))
return cards_data
return self.info_data.get('cards')<|docstring|>Card collection.<|endoftext|>
|
9e033ebd1267c3439842d0f30b99101507140939f1380f060d57a9639000a536
|
def __init__(self, bot, filepath, session=None):
'Init.'
self.bot = bot
self.filepath = filepath
self.settings = nested_dict()
self.settings.update(dataIO.load_json(filepath))
self.session = session
|
Init.
|
crprofile/crprofile.py
|
__init__
|
zodpixel/SML-Cogs
| 17 |
python
|
def __init__(self, bot, filepath, session=None):
self.bot = bot
self.filepath = filepath
self.settings = nested_dict()
self.settings.update(dataIO.load_json(filepath))
self.session = session
|
def __init__(self, bot, filepath, session=None):
self.bot = bot
self.filepath = filepath
self.settings = nested_dict()
self.settings.update(dataIO.load_json(filepath))
self.session = session<|docstring|>Init.<|endoftext|>
|
7acb98358b5c697de828e64cee5f93adecbcaff363d2ceeb68da7103405184d5
|
def init_server(self, server):
'Initialized server settings.\n\n This will wipe all clan data and player data.\n '
self.settings['servers'][server.id] = self.SERVER_DEFAULTS
self.save()
|
Initialized server settings.
This will wipe all clan data and player data.
|
crprofile/crprofile.py
|
init_server
|
zodpixel/SML-Cogs
| 17 |
python
|
def init_server(self, server):
'Initialized server settings.\n\n This will wipe all clan data and player data.\n '
self.settings['servers'][server.id] = self.SERVER_DEFAULTS
self.save()
|
def init_server(self, server):
'Initialized server settings.\n\n This will wipe all clan data and player data.\n '
self.settings['servers'][server.id] = self.SERVER_DEFAULTS
self.save()<|docstring|>Initialized server settings.
This will wipe all clan data and player data.<|endoftext|>
|
026f949cc7d13102f3c874d04a1d52d972326cae484ffd18bba873802014a5a0
|
def init_players(self, server):
'Initialized clan settings.'
self.settings['servers'][server.id]['players'] = {}
self.save()
|
Initialized clan settings.
|
crprofile/crprofile.py
|
init_players
|
zodpixel/SML-Cogs
| 17 |
python
|
def init_players(self, server):
self.settings['servers'][server.id]['players'] = {}
self.save()
|
def init_players(self, server):
self.settings['servers'][server.id]['players'] = {}
self.save()<|docstring|>Initialized clan settings.<|endoftext|>
|
f62704c24f01a0cacd277be0d43a6301ae028c00d5aa471640130657d1cabc2f
|
def check_server(self, server):
'Make sure server exists in settings.'
if (server.id not in self.settings['servers']):
self.settings['servers'][server.id] = self.SERVER_DEFAULTS
self.save()
|
Make sure server exists in settings.
|
crprofile/crprofile.py
|
check_server
|
zodpixel/SML-Cogs
| 17 |
python
|
def check_server(self, server):
if (server.id not in self.settings['servers']):
self.settings['servers'][server.id] = self.SERVER_DEFAULTS
self.save()
|
def check_server(self, server):
if (server.id not in self.settings['servers']):
self.settings['servers'][server.id] = self.SERVER_DEFAULTS
self.save()<|docstring|>Make sure server exists in settings.<|endoftext|>
|
22bf7429669b8a7234cc43503d7f512d4e8cc86f0cdff621453ae1ed7de962e4
|
def get_players(self, server):
'CR Players settings by server.'
return self.settings['servers'][server.id]['players']
|
CR Players settings by server.
|
crprofile/crprofile.py
|
get_players
|
zodpixel/SML-Cogs
| 17 |
python
|
def get_players(self, server):
return self.settings['servers'][server.id]['players']
|
def get_players(self, server):
return self.settings['servers'][server.id]['players']<|docstring|>CR Players settings by server.<|endoftext|>
|
6e3de94b19fd336e015d9fe626150b15934960eb9a2658b0f9dba60d7c2365b5
|
def save(self):
'Save data to disk.'
dataIO.save_json(self.filepath, self.settings)
|
Save data to disk.
|
crprofile/crprofile.py
|
save
|
zodpixel/SML-Cogs
| 17 |
python
|
def save(self):
dataIO.save_json(self.filepath, self.settings)
|
def save(self):
dataIO.save_json(self.filepath, self.settings)<|docstring|>Save data to disk.<|endoftext|>
|
d30ebdcf5a77ce8f796fd12ce540f82e1f4a35efed3223151363b5eb27e518cb
|
def set_player(self, server, member, tag):
'Associate player tag with Discord member.\n\n If tag already exists for member, overwrites it.\n '
self.check_server(server)
tag = SCTag(tag).tag
if ('players' not in self.settings['servers'][server.id]):
self.settings['servers'][server.id]['players'] = {}
players = self.settings['servers'][server.id]['players']
players[member.id] = tag
self.settings['servers'][server.id]['players'] = players
self.save()
|
Associate player tag with Discord member.
If tag already exists for member, overwrites it.
|
crprofile/crprofile.py
|
set_player
|
zodpixel/SML-Cogs
| 17 |
python
|
def set_player(self, server, member, tag):
'Associate player tag with Discord member.\n\n If tag already exists for member, overwrites it.\n '
self.check_server(server)
tag = SCTag(tag).tag
if ('players' not in self.settings['servers'][server.id]):
self.settings['servers'][server.id]['players'] = {}
players = self.settings['servers'][server.id]['players']
players[member.id] = tag
self.settings['servers'][server.id]['players'] = players
self.save()
|
def set_player(self, server, member, tag):
'Associate player tag with Discord member.\n\n If tag already exists for member, overwrites it.\n '
self.check_server(server)
tag = SCTag(tag).tag
if ('players' not in self.settings['servers'][server.id]):
self.settings['servers'][server.id]['players'] = {}
players = self.settings['servers'][server.id]['players']
players[member.id] = tag
self.settings['servers'][server.id]['players'] = players
self.save()<|docstring|>Associate player tag with Discord member.
If tag already exists for member, overwrites it.<|endoftext|>
|
9c9925099f597a15a08cd5642b39facebc86006bce83671c46fb5775f2473357
|
def rm_player_tag(self, server, member=None, tag=None):
'Remove player tag from settings.'
self.check_server(server)
if (member is not None):
try:
self.settings['servers'][server.id]['players'].pop(member.id, None)
except KeyError:
pass
self.save()
if (tag is not None):
try:
players = self.settings['servers'][server.id]['players'].copy()
for (member_id, player_tag) in players.items():
if (player_tag == tag):
self.settings['servers'][server.id]['players'].pop(member_id, None)
except KeyError:
pass
self.save()
|
Remove player tag from settings.
|
crprofile/crprofile.py
|
rm_player_tag
|
zodpixel/SML-Cogs
| 17 |
python
|
def rm_player_tag(self, server, member=None, tag=None):
self.check_server(server)
if (member is not None):
try:
self.settings['servers'][server.id]['players'].pop(member.id, None)
except KeyError:
pass
self.save()
if (tag is not None):
try:
players = self.settings['servers'][server.id]['players'].copy()
for (member_id, player_tag) in players.items():
if (player_tag == tag):
self.settings['servers'][server.id]['players'].pop(member_id, None)
except KeyError:
pass
self.save()
|
def rm_player_tag(self, server, member=None, tag=None):
self.check_server(server)
if (member is not None):
try:
self.settings['servers'][server.id]['players'].pop(member.id, None)
except KeyError:
pass
self.save()
if (tag is not None):
try:
players = self.settings['servers'][server.id]['players'].copy()
for (member_id, player_tag) in players.items():
if (player_tag == tag):
self.settings['servers'][server.id]['players'].pop(member_id, None)
except KeyError:
pass
self.save()<|docstring|>Remove player tag from settings.<|endoftext|>
|
b7317da3fc85e4c2558ed925fbafeb5b0715ce35b326f0fd3f1b8b1f0a6eaa6c
|
def rm_tag(self, server, tag):
'Remove player tag from settings by tag'
|
Remove player tag from settings by tag
|
crprofile/crprofile.py
|
rm_tag
|
zodpixel/SML-Cogs
| 17 |
python
|
def rm_tag(self, server, tag):
|
def rm_tag(self, server, tag):
<|docstring|>Remove player tag from settings by tag<|endoftext|>
|
730d5c38a3f57035a095b19506ef8669b51fcd16f8013ba9014fd954894c46d4
|
def tag2member(self, server, tag):
'Return Discord member from player tag.'
try:
players = self.settings['servers'][server.id]['players']
for (member_id, player_tag) in players.items():
if (player_tag == tag):
return server.get_member(member_id)
except KeyError:
pass
return None
|
Return Discord member from player tag.
|
crprofile/crprofile.py
|
tag2member
|
zodpixel/SML-Cogs
| 17 |
python
|
def tag2member(self, server, tag):
try:
players = self.settings['servers'][server.id]['players']
for (member_id, player_tag) in players.items():
if (player_tag == tag):
return server.get_member(member_id)
except KeyError:
pass
return None
|
def tag2member(self, server, tag):
try:
players = self.settings['servers'][server.id]['players']
for (member_id, player_tag) in players.items():
if (player_tag == tag):
return server.get_member(member_id)
except KeyError:
pass
return None<|docstring|>Return Discord member from player tag.<|endoftext|>
|
2af56e96063401f6d117696cb7290c7596a1369daf5387ca00d8879fdca9d28a
|
def server_settings(self, server):
'Return server settings.'
return self.settings['servers'][server.id]
|
Return server settings.
|
crprofile/crprofile.py
|
server_settings
|
zodpixel/SML-Cogs
| 17 |
python
|
def server_settings(self, server):
return self.settings['servers'][server.id]
|
def server_settings(self, server):
return self.settings['servers'][server.id]<|docstring|>Return server settings.<|endoftext|>
|
73cecf3a7fa33ed6d0da881a388e2be48c4a69ca64b8d9aafeb716d45ad251f2
|
async def player_data(self, tag):
'Return CRPlayerModel by tag.'
tag = SCTag(tag).tag
error = False
data = {'info': {}, 'chests': {}}
if (self.api_provider == 'official'):
info_url = 'https://api.clashroyale.com/v1/players/%23{}'.format(tag)
chest_url = 'https://api.clashroyale.com/v1/players/%23{}/upcomingchests'.format(tag)
headers = {'Authorization': 'Bearer {}'.format(self.official_auth)}
else:
info_url = 'https://api.royaleapi.com/player/{}'.format(tag)
chest_url = 'https://api.royaleapi.com/player/{}/chests'.format(tag)
headers = {'Authorization': 'Bearer {}'.format(self.auth)}
conn = aiohttp.TCPConnector(family=socket.AF_INET, verify_ssl=False)
try:
for url in [info_url, chest_url]:
async with self.session.get(url, headers=headers) as resp:
if (resp.status != 200):
error = True
data = (await resp.json())
raise APIError(status=resp.status, message=data.get('message'), reason=data.get('reason'))
elif (url == info_url):
data['info'] = (await resp.json())
elif (url == chest_url):
data['chests'] = (await resp.json())
except json.decoder.JSONDecodeError:
raise APIError()
except asyncio.TimeoutError:
raise APIError()
return CRPlayerModel(data=data, error=error, api_provider=self.api_provider)
|
Return CRPlayerModel by tag.
|
crprofile/crprofile.py
|
player_data
|
zodpixel/SML-Cogs
| 17 |
python
|
async def player_data(self, tag):
tag = SCTag(tag).tag
error = False
data = {'info': {}, 'chests': {}}
if (self.api_provider == 'official'):
info_url = 'https://api.clashroyale.com/v1/players/%23{}'.format(tag)
chest_url = 'https://api.clashroyale.com/v1/players/%23{}/upcomingchests'.format(tag)
headers = {'Authorization': 'Bearer {}'.format(self.official_auth)}
else:
info_url = 'https://api.royaleapi.com/player/{}'.format(tag)
chest_url = 'https://api.royaleapi.com/player/{}/chests'.format(tag)
headers = {'Authorization': 'Bearer {}'.format(self.auth)}
conn = aiohttp.TCPConnector(family=socket.AF_INET, verify_ssl=False)
try:
for url in [info_url, chest_url]:
async with self.session.get(url, headers=headers) as resp:
if (resp.status != 200):
error = True
data = (await resp.json())
raise APIError(status=resp.status, message=data.get('message'), reason=data.get('reason'))
elif (url == info_url):
data['info'] = (await resp.json())
elif (url == chest_url):
data['chests'] = (await resp.json())
except json.decoder.JSONDecodeError:
raise APIError()
except asyncio.TimeoutError:
raise APIError()
return CRPlayerModel(data=data, error=error, api_provider=self.api_provider)
|
async def player_data(self, tag):
tag = SCTag(tag).tag
error = False
data = {'info': {}, 'chests': {}}
if (self.api_provider == 'official'):
info_url = 'https://api.clashroyale.com/v1/players/%23{}'.format(tag)
chest_url = 'https://api.clashroyale.com/v1/players/%23{}/upcomingchests'.format(tag)
headers = {'Authorization': 'Bearer {}'.format(self.official_auth)}
else:
info_url = 'https://api.royaleapi.com/player/{}'.format(tag)
chest_url = 'https://api.royaleapi.com/player/{}/chests'.format(tag)
headers = {'Authorization': 'Bearer {}'.format(self.auth)}
conn = aiohttp.TCPConnector(family=socket.AF_INET, verify_ssl=False)
try:
for url in [info_url, chest_url]:
async with self.session.get(url, headers=headers) as resp:
if (resp.status != 200):
error = True
data = (await resp.json())
raise APIError(status=resp.status, message=data.get('message'), reason=data.get('reason'))
elif (url == info_url):
data['info'] = (await resp.json())
elif (url == chest_url):
data['chests'] = (await resp.json())
except json.decoder.JSONDecodeError:
raise APIError()
except asyncio.TimeoutError:
raise APIError()
return CRPlayerModel(data=data, error=error, api_provider=self.api_provider)<|docstring|>Return CRPlayerModel by tag.<|endoftext|>
|
3f018f4e951e32ffa852e13abcd3c2baea31d492154cde341625eb0f745eaf4f
|
def cached_player_data(self, tag):
'Return cached data by tag.'
file_path = self.cached_filepath(tag)
if (not os.path.exists(file_path)):
return None
data = dataIO.load_json(file_path)
return CRPlayerModel(is_cache=True, data=data)
|
Return cached data by tag.
|
crprofile/crprofile.py
|
cached_player_data
|
zodpixel/SML-Cogs
| 17 |
python
|
def cached_player_data(self, tag):
file_path = self.cached_filepath(tag)
if (not os.path.exists(file_path)):
return None
data = dataIO.load_json(file_path)
return CRPlayerModel(is_cache=True, data=data)
|
def cached_player_data(self, tag):
file_path = self.cached_filepath(tag)
if (not os.path.exists(file_path)):
return None
data = dataIO.load_json(file_path)
return CRPlayerModel(is_cache=True, data=data)<|docstring|>Return cached data by tag.<|endoftext|>
|
e3e0775736b57633c3c9b4a9468076281ebd23b8f9117df08251f814c3838c0e
|
def cached_player_data_timestamp(self, tag):
'Return timestamp in days-since format of cached data.'
file_path = self.cached_filepath(tag)
timestamp = dt.datetime.fromtimestamp(os.path.getmtime(file_path))
passed = (dt.datetime.now() - timestamp)
days = passed.days
(hours, remainder) = divmod(passed.seconds, 3600)
(minutes, seconds) = divmod(remainder, 60)
p = inflect.engine()
days_str = ('{} {} '.format(days, p.plural('day', days)) if (days > 0) else '')
passed_str = '{days} {hours} {hr} {minutes} {mn} {seconds} {sec} ago'.format(days=days_str, hours=hours, hr=p.plural('hour', hours), minutes=minutes, mn=p.plural('minute', minutes), seconds=seconds, sec=p.plural('second', seconds))
return passed_str
|
Return timestamp in days-since format of cached data.
|
crprofile/crprofile.py
|
cached_player_data_timestamp
|
zodpixel/SML-Cogs
| 17 |
python
|
def cached_player_data_timestamp(self, tag):
file_path = self.cached_filepath(tag)
timestamp = dt.datetime.fromtimestamp(os.path.getmtime(file_path))
passed = (dt.datetime.now() - timestamp)
days = passed.days
(hours, remainder) = divmod(passed.seconds, 3600)
(minutes, seconds) = divmod(remainder, 60)
p = inflect.engine()
days_str = ('{} {} '.format(days, p.plural('day', days)) if (days > 0) else )
passed_str = '{days} {hours} {hr} {minutes} {mn} {seconds} {sec} ago'.format(days=days_str, hours=hours, hr=p.plural('hour', hours), minutes=minutes, mn=p.plural('minute', minutes), seconds=seconds, sec=p.plural('second', seconds))
return passed_str
|
def cached_player_data_timestamp(self, tag):
file_path = self.cached_filepath(tag)
timestamp = dt.datetime.fromtimestamp(os.path.getmtime(file_path))
passed = (dt.datetime.now() - timestamp)
days = passed.days
(hours, remainder) = divmod(passed.seconds, 3600)
(minutes, seconds) = divmod(remainder, 60)
p = inflect.engine()
days_str = ('{} {} '.format(days, p.plural('day', days)) if (days > 0) else )
passed_str = '{days} {hours} {hr} {minutes} {mn} {seconds} {sec} ago'.format(days=days_str, hours=hours, hr=p.plural('hour', hours), minutes=minutes, mn=p.plural('minute', minutes), seconds=seconds, sec=p.plural('second', seconds))
return passed_str<|docstring|>Return timestamp in days-since format of cached data.<|endoftext|>
|
cfd0eae010b15bc1e9cf63a0cef6cce57f437e437b47baff43816eef3ec4da2d
|
@staticmethod
def cached_filepath(tag):
'Cached clan data file path'
return os.path.join(PATH_PLAYERS, '{}.json'.format(tag))
|
Cached clan data file path
|
crprofile/crprofile.py
|
cached_filepath
|
zodpixel/SML-Cogs
| 17 |
python
|
@staticmethod
def cached_filepath(tag):
return os.path.join(PATH_PLAYERS, '{}.json'.format(tag))
|
@staticmethod
def cached_filepath(tag):
return os.path.join(PATH_PLAYERS, '{}.json'.format(tag))<|docstring|>Cached clan data file path<|endoftext|>
|
4449e02702611c823bac854e068a66f97009e491274266300c5c83ad32633b83
|
async def member2tag(self, server, member):
'Return player tag from member.'
try:
players = self.settings['servers'][server.id]['players']
for (member_id, player_tag) in players.items():
if (member_id == member.id):
return player_tag
except KeyError:
pass
if self.verify_url:
url = ((self.verify_url + '&discord_id=') + member.id)
async with self.session.get(url) as resp:
data = (await resp.json())
results = data.get('results', [])
if results:
return results[0].get('player_tag')
return None
|
Return player tag from member.
|
crprofile/crprofile.py
|
member2tag
|
zodpixel/SML-Cogs
| 17 |
python
|
async def member2tag(self, server, member):
try:
players = self.settings['servers'][server.id]['players']
for (member_id, player_tag) in players.items():
if (member_id == member.id):
return player_tag
except KeyError:
pass
if self.verify_url:
url = ((self.verify_url + '&discord_id=') + member.id)
async with self.session.get(url) as resp:
data = (await resp.json())
results = data.get('results', [])
if results:
return results[0].get('player_tag')
return None
|
async def member2tag(self, server, member):
try:
players = self.settings['servers'][server.id]['players']
for (member_id, player_tag) in players.items():
if (member_id == member.id):
return player_tag
except KeyError:
pass
if self.verify_url:
url = ((self.verify_url + '&discord_id=') + member.id)
async with self.session.get(url) as resp:
data = (await resp.json())
results = data.get('results', [])
if results:
return results[0].get('player_tag')
return None<|docstring|>Return player tag from member.<|endoftext|>
|
e60906ebe26238464010ff96e25e95a12cf35939f93ee9ec5e4f3e814bb07e00
|
def emoji(self, name=None, key=None):
'Chest emojis by api key name or key.\n\n name is used by this cog.\n key is values returned by the api.\n Use key only if name is not set\n '
emojis = {'Silver': 'chestsilver', 'Gold': 'chestgold', 'Giant': 'chestgiant', 'Magic': 'chestmagical', 'super_magical': 'chestsupermagical', 'legendary': 'chestlegendary', 'epic': 'chestepic'}
if (name is None):
if (key in emojis):
name = emojis[key]
for server in self.bot.servers:
for emoji in server.emojis:
if (emoji.name == name):
return '<:{}:{}>'.format(emoji.name, emoji.id)
return ''
|
Chest emojis by api key name or key.
name is used by this cog.
key is values returned by the api.
Use key only if name is not set
|
crprofile/crprofile.py
|
emoji
|
zodpixel/SML-Cogs
| 17 |
python
|
def emoji(self, name=None, key=None):
'Chest emojis by api key name or key.\n\n name is used by this cog.\n key is values returned by the api.\n Use key only if name is not set\n '
emojis = {'Silver': 'chestsilver', 'Gold': 'chestgold', 'Giant': 'chestgiant', 'Magic': 'chestmagical', 'super_magical': 'chestsupermagical', 'legendary': 'chestlegendary', 'epic': 'chestepic'}
if (name is None):
if (key in emojis):
name = emojis[key]
for server in self.bot.servers:
for emoji in server.emojis:
if (emoji.name == name):
return '<:{}:{}>'.format(emoji.name, emoji.id)
return
|
def emoji(self, name=None, key=None):
'Chest emojis by api key name or key.\n\n name is used by this cog.\n key is values returned by the api.\n Use key only if name is not set\n '
emojis = {'Silver': 'chestsilver', 'Gold': 'chestgold', 'Giant': 'chestgiant', 'Magic': 'chestmagical', 'super_magical': 'chestsupermagical', 'legendary': 'chestlegendary', 'epic': 'chestepic'}
if (name is None):
if (key in emojis):
name = emojis[key]
for server in self.bot.servers:
for emoji in server.emojis:
if (emoji.name == name):
return '<:{}:{}>'.format(emoji.name, emoji.id)
return <|docstring|>Chest emojis by api key name or key.
name is used by this cog.
key is values returned by the api.
Use key only if name is not set<|endoftext|>
|
ffac5c4dcbb0fb1ceb8bd10b3ddfd3405ba08f7f9cb4f2c81fdce9cb848bbed2
|
@property
def profile_api_url(self):
'Profile API URL.'
return self.settings['profile_api_url']
|
Profile API URL.
|
crprofile/crprofile.py
|
profile_api_url
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def profile_api_url(self):
return self.settings['profile_api_url']
|
@property
def profile_api_url(self):
return self.settings['profile_api_url']<|docstring|>Profile API URL.<|endoftext|>
|
90c966786f2be9e8872f7aa9568ac522b13133903caa061c85d9b9b194892e8c
|
@profile_api_url.setter
def profile_api_url(self, value):
'Set Profile API URL.'
self.settings['profile_api_url'] = value
self.save()
|
Set Profile API URL.
|
crprofile/crprofile.py
|
profile_api_url
|
zodpixel/SML-Cogs
| 17 |
python
|
@profile_api_url.setter
def profile_api_url(self, value):
self.settings['profile_api_url'] = value
self.save()
|
@profile_api_url.setter
def profile_api_url(self, value):
self.settings['profile_api_url'] = value
self.save()<|docstring|>Set Profile API URL.<|endoftext|>
|
ea2775cad77a8788bac8e622e981a67ef389041028fb0f96c644eefe2a5475ee
|
@property
def profile_api_token(self):
'Profile API Token.'
return self.settings.get('profile_api_token', None)
|
Profile API Token.
|
crprofile/crprofile.py
|
profile_api_token
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def profile_api_token(self):
return self.settings.get('profile_api_token', None)
|
@property
def profile_api_token(self):
return self.settings.get('profile_api_token', None)<|docstring|>Profile API Token.<|endoftext|>
|
fca023c30857454c7ec392a804a6338d3b57b751498f35a6b4bcfb335858998e
|
@profile_api_token.setter
def profile_api_token(self, value):
'Set Profile API Token.'
self.settings['profile_api_token'] = value
self.save()
|
Set Profile API Token.
|
crprofile/crprofile.py
|
profile_api_token
|
zodpixel/SML-Cogs
| 17 |
python
|
@profile_api_token.setter
def profile_api_token(self, value):
self.settings['profile_api_token'] = value
self.save()
|
@profile_api_token.setter
def profile_api_token(self, value):
self.settings['profile_api_token'] = value
self.save()<|docstring|>Set Profile API Token.<|endoftext|>
|
b0970c5bb8448d19bb2c948ce19463d6f314d3645c8b9696e1d93502e5257eb7
|
@property
def badge_url(self):
'Clan Badge URL.'
return self.settings.get('badge_url_base', None)
|
Clan Badge URL.
|
crprofile/crprofile.py
|
badge_url
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def badge_url(self):
return self.settings.get('badge_url_base', None)
|
@property
def badge_url(self):
return self.settings.get('badge_url_base', None)<|docstring|>Clan Badge URL.<|endoftext|>
|
39d572ade99dabee4cf7d4aab6970b9baf9f00cd15d0081bf75f3446234628af
|
@badge_url.setter
def badge_url(self, value):
'lan Badge URL'
self.settings['badge_url_base'] = value
self.save()
|
lan Badge URL
|
crprofile/crprofile.py
|
badge_url
|
zodpixel/SML-Cogs
| 17 |
python
|
@badge_url.setter
def badge_url(self, value):
self.settings['badge_url_base'] = value
self.save()
|
@badge_url.setter
def badge_url(self, value):
self.settings['badge_url_base'] = value
self.save()<|docstring|>lan Badge URL<|endoftext|>
|
107e6fc3224a3d3a8b0762bca0b128c4818603f1bc7b4f8d7445ff4d60e64c6f
|
@property
def auth(self):
'Authentication token'
return self.settings.get('auth')
|
Authentication token
|
crprofile/crprofile.py
|
auth
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def auth(self):
return self.settings.get('auth')
|
@property
def auth(self):
return self.settings.get('auth')<|docstring|>Authentication token<|endoftext|>
|
92ebbeff06a274e1d2642b33f8666ac379b19f461b791f174d845ec96a5f7e24
|
@auth.setter
def auth(self, value):
'Set authentication token.'
self.settings['auth'] = value
self.save()
|
Set authentication token.
|
crprofile/crprofile.py
|
auth
|
zodpixel/SML-Cogs
| 17 |
python
|
@auth.setter
def auth(self, value):
self.settings['auth'] = value
self.save()
|
@auth.setter
def auth(self, value):
self.settings['auth'] = value
self.save()<|docstring|>Set authentication token.<|endoftext|>
|
efb2beca04972dd5dc209771e5464aa551ff97a42760ca7dbcbcd871224bf241
|
@verify_url.setter
def verify_url(self, value):
'Verification endpoint.'
self.settings['verify_url'] = value
self.save()
|
Verification endpoint.
|
crprofile/crprofile.py
|
verify_url
|
zodpixel/SML-Cogs
| 17 |
python
|
@verify_url.setter
def verify_url(self, value):
self.settings['verify_url'] = value
self.save()
|
@verify_url.setter
def verify_url(self, value):
self.settings['verify_url'] = value
self.save()<|docstring|>Verification endpoint.<|endoftext|>
|
1e16f1cccc481c6378e12392fb1428a3957b4fa9ef632224c2941c7812705279
|
@property
def official_auth(self):
'Authentication token'
return self.settings.get('official_auth')
|
Authentication token
|
crprofile/crprofile.py
|
official_auth
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def official_auth(self):
return self.settings.get('official_auth')
|
@property
def official_auth(self):
return self.settings.get('official_auth')<|docstring|>Authentication token<|endoftext|>
|
c5109024ab68a486ea4a84539094c650177ef4243de85b1123e8c1774ba43b04
|
@official_auth.setter
def official_auth(self, value):
'Set authentication token.'
self.settings['official_auth'] = value
self.save()
|
Set authentication token.
|
crprofile/crprofile.py
|
official_auth
|
zodpixel/SML-Cogs
| 17 |
python
|
@official_auth.setter
def official_auth(self, value):
self.settings['official_auth'] = value
self.save()
|
@official_auth.setter
def official_auth(self, value):
self.settings['official_auth'] = value
self.save()<|docstring|>Set authentication token.<|endoftext|>
|
75124a2f614d19bf6cc3b7bdbea2e083637d1cb23ac7f125efdfdbeae9387089
|
@property
def api_provider(self):
'API provider. Can use either cr-api.com or official API.\n\n Accepted values:\n cr-api\n official\n '
provider = self.settings.get('api_provider')
if (provider is None):
provider = 'cr-api'
return provider
|
API provider. Can use either cr-api.com or official API.
Accepted values:
cr-api
official
|
crprofile/crprofile.py
|
api_provider
|
zodpixel/SML-Cogs
| 17 |
python
|
@property
def api_provider(self):
'API provider. Can use either cr-api.com or official API.\n\n Accepted values:\n cr-api\n official\n '
provider = self.settings.get('api_provider')
if (provider is None):
provider = 'cr-api'
return provider
|
@property
def api_provider(self):
'API provider. Can use either cr-api.com or official API.\n\n Accepted values:\n cr-api\n official\n '
provider = self.settings.get('api_provider')
if (provider is None):
provider = 'cr-api'
return provider<|docstring|>API provider. Can use either cr-api.com or official API.
Accepted values:
cr-api
official<|endoftext|>
|
dc83781c5b012502688aa8a6b52e86253c02afb829962b09e7513d1cb8ccf89d
|
def set_resources(self, server, value):
'Show gold/gems or not.'
self.settings[server.id]['show_resources'] = value
|
Show gold/gems or not.
|
crprofile/crprofile.py
|
set_resources
|
zodpixel/SML-Cogs
| 17 |
python
|
def set_resources(self, server, value):
self.settings[server.id]['show_resources'] = value
|
def set_resources(self, server, value):
self.settings[server.id]['show_resources'] = value<|docstring|>Show gold/gems or not.<|endoftext|>
|
0cadb41ed6a5f3595e11e3eac9ed5eb014ac20ceef9d0dfa17dea867f14c40f5
|
def show_resources(self, server):
'Show gold/gems or not.'
try:
return self.settings[server.id]['show_resources']
except KeyError:
return False
|
Show gold/gems or not.
|
crprofile/crprofile.py
|
show_resources
|
zodpixel/SML-Cogs
| 17 |
python
|
def show_resources(self, server):
try:
return self.settings[server.id]['show_resources']
except KeyError:
return False
|
def show_resources(self, server):
try:
return self.settings[server.id]['show_resources']
except KeyError:
return False<|docstring|>Show gold/gems or not.<|endoftext|>
|
24c04fca35e92a7a138d1bc1154014c190483a0e7c60305733610907819169b2
|
def __init__(self, bot):
'Init.'
self.bot = bot
self.bot_emoji = BotEmoji(bot)
self.session = aiohttp.ClientSession()
self.model = Settings(bot, JSON, session=self.session)
|
Init.
|
crprofile/crprofile.py
|
__init__
|
zodpixel/SML-Cogs
| 17 |
python
|
def __init__(self, bot):
self.bot = bot
self.bot_emoji = BotEmoji(bot)
self.session = aiohttp.ClientSession()
self.model = Settings(bot, JSON, session=self.session)
|
def __init__(self, bot):
self.bot = bot
self.bot_emoji = BotEmoji(bot)
self.session = aiohttp.ClientSession()
self.model = Settings(bot, JSON, session=self.session)<|docstring|>Init.<|endoftext|>
|
903fdc45996b721a9de6109e717aa549596efb972b38a77584b5bab285787d69
|
async def player_data(self, tag):
'Return CRPlayerModel by tag.'
data = (await self.model.player_data(tag))
return data
|
Return CRPlayerModel by tag.
|
crprofile/crprofile.py
|
player_data
|
zodpixel/SML-Cogs
| 17 |
python
|
async def player_data(self, tag):
data = (await self.model.player_data(tag))
return data
|
async def player_data(self, tag):
data = (await self.model.player_data(tag))
return data<|docstring|>Return CRPlayerModel by tag.<|endoftext|>
|
3000274e103df0f90dc90ead17400beecfb90ab35c68a410e3dd732bd02fc2f0
|
@commands.group(pass_context=True, no_pm=True)
@checks.is_owner()
async def crprofileset(self, ctx):
'Clash Royale profile API.'
if (ctx.invoked_subcommand is None):
(await self.bot.send_cmd_help(ctx))
|
Clash Royale profile API.
|
crprofile/crprofile.py
|
crprofileset
|
zodpixel/SML-Cogs
| 17 |
python
|
@commands.group(pass_context=True, no_pm=True)
@checks.is_owner()
async def crprofileset(self, ctx):
if (ctx.invoked_subcommand is None):
(await self.bot.send_cmd_help(ctx))
|
@commands.group(pass_context=True, no_pm=True)
@checks.is_owner()
async def crprofileset(self, ctx):
if (ctx.invoked_subcommand is None):
(await self.bot.send_cmd_help(ctx))<|docstring|>Clash Royale profile API.<|endoftext|>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.