Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_teams(ids):
"""Gets teams by ID
ids list the IDs of the teams
return list the teams
"""
teams = cassiopeia.core.requests.call_with_ensured_size(cassiopeia.dto.teamapi.get_teams_by_id, 10, ids)
# Load required data if loading policy is eager
if(cassiopeia.core.requests.load_policy is cassiopeia.type.core.common.LoadPolicy.eager):
summoner_ids = set()
for _, team in teams.items():
summoner_ids |= team.summoner_ids
cassiopeia.riotapi.get_summoners_by_id(list(summoner_ids)) if summoner_ids else None
return [cassiopeia.type.core.team.Team(teams[id_]) for id_ in ids]
import datetime
import cassiopeia.type.core.common
import cassiopeia.type.dto.status
@cassiopeia.type.core.common.inheritdocs
class Shard(cassiopeia.type.core.common.CassiopeiaObject):
dto_type = cassiopeia.type.dto.status.Shard
def __str__(self):
return self.name
@property
def host_name(self):
"""
Returns:
str: the domain name of the server
"""
return self.data.hostname
@property
def locales(self):
def mode(self):
"""
Returns:
GameMode: the game mode
"""
return cassiopeia.type.core.common.GameMode(self.data.gameMode) if self.data.gameMode else None
def map(self):
"""
Returns:
Map: the map that the game was played on
"""
return cassiopeia.type.core.common.Map(self.data.mapId) if self.data.mapId else None
def _sa_bind_summoner():
global Summoner
@cassiopeia.type.core.common.inheritdocs
class Summoner(Summoner, cassiopeia.type.dto.common.BaseDB):
__tablename__ = "Summoner"
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
name = sqlalchemy.Column(sqlalchemy.String(30))
profileIconId = sqlalchemy.Column(sqlalchemy.Integer)
revisionDate = sqlalchemy.Column(sqlalchemy.BigInteger)
summonerLevel = sqlalchemy.Column(sqlalchemy.Integer)
import datetime
import cassiopeia.riotapi
import cassiopeia.type.core.common
import cassiopeia.type.dto.currentgame
@cassiopeia.type.core.common.inheritdocs
class Participant(cassiopeia.type.core.common.CassiopeiaObject):
dto_type = cassiopeia.type.dto.currentgame.CurrentGameParticipant
def __str__(self):
return "{player} ({champ})".format(player=self.summoner_name, champ=self.champion)
@property
def bot(self):
"""
Returns:
bool: whether the participant is a bot
"""
return self.data.bot
@property
def champion(self):
"""
def _sa_bind_participant():
global Participant
@cassiopeia.type.core.common.inheritdocs
class Participant(Participant, cassiopeia.type.dto.common.BaseDB):
__tablename__ = "FeaturedGameParticipant"
bot = sqlalchemy.Column(sqlalchemy.Boolean)
championId = sqlalchemy.Column(sqlalchemy.Integer)
profileIconId = sqlalchemy.Column(sqlalchemy.Integer)
spell1Id = sqlalchemy.Column(sqlalchemy.Integer)
spell2Id = sqlalchemy.Column(sqlalchemy.Integer)
summonerName = sqlalchemy.Column(sqlalchemy.String(30))
teamId = sqlalchemy.Column(sqlalchemy.Integer)
_id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
_game_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey("FeaturedGameInfo.gameId", ondelete="CASCADE"))
def type(self):
"""
Returns:
GameType: the game type
"""
return cassiopeia.type.core.common.gametype(self.data.gameType) if self.data.gameType else None
def ascended(self):
"""
Returns:
Ascended: what died in the event
"""
return cassiopeia.type.core.common.Ascended(self.data.ascendedType) if self.data.ascendedType else None
########################
if cassiopeia.type.dto.common.sqlalchemy_imported:
class HasAllStatus(cassiopeia.type.dto.common.BaseDB):
__tablename__ = "HasAll"
class_ = sqlalchemy.Column(sqlalchemy.String(50), primary_key=True)
have_all = sqlalchemy.Column(sqlalchemy.Boolean)
@staticmethod
def get_name(class_):
return "{module}.{name}".format(module=class_.dto_type.__module__, name=class_.dto_type.__name__)
def __init__(self, class_, have_all=True):
self.class_ = HasAllStatus.get_name(class_)
self.have_all = have_all
@cassiopeia.type.core.common.inheritdocs
class SQLAlchemyDB(DataStore):
class Iterator(object):
def __init__(self, class_, result):
self.class_ = class_
self.result = result
def __next__(self):
try:
val = self.class_(self.result[self.index])
self.index += 1
return val
except IndexError:
raise StopIteration
def __iter__(self):
self.index = 0