How to use the cassiopeia.type function in cassiopeia

To help you get started, we’ve selected a few cassiopeia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github meraki-analytics / cassiopeia / cassiopeia / type / core / currentgame.py View on Github external
def _sa_rebind_all():
    Participant.dto_type = cassiopeia.type.dto.currentgame.CurrentGameParticipant
    Ban.dto_type = cassiopeia.type.dto.currentgame.BannedChampion
    Game.dto_type = cassiopeia.type.dto.currentgame.CurrentGameInfo
github meraki-analytics / kernel / merakikernel / integrations / cassiopeia / gamebindings.py View on Github external
def get_recent_games(summoner_id):
    region = cassiopeia.dto.requests.region
    return cassiopeia.type.dto.game.RecentGames(merakikernel.riotapi.gameapi.recent_games(region, str(summoner_id)))
github meraki-analytics / cassiopeia / cassiopeia / core / leagueapi.py View on Github external
def __get_league_entries_by_team_id(ids):
    leagues = cassiopeia.core.requests.call_with_ensured_size(cassiopeia.dto.leagueapi.get_league_entries_by_team, 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()
        team_ids = set()
        for team in leagues.items():
            for league in team[1]:
                summoner_ids = summoner_ids | league.summoner_ids
                team_ids = team_ids | league.team_ids
        cassiopeia.riotapi.get_summoners_by_id(list(summoner_ids)) if summoner_ids else None
        cassiopeia.riotapi.get_teams(list(team_ids)) if team_ids else None

    if not isinstance(ids, list):
        return [cassiopeia.type.core.league.League(league) for league in leagues[ids]]
    else:
        return [[cassiopeia.type.core.league.League(league) for league in leagues.get(id_, []) if leagues.get(id_, [])] for id_ in ids]
github meraki-analytics / cassiopeia / cassiopeia / type / core / summoner.py View on Github external
import datetime

import cassiopeia.riotapi
import cassiopeia.type.core.common
import cassiopeia.type.dto.summoner


@cassiopeia.type.core.common.inheritdocs
class RunePage(cassiopeia.type.core.common.CassiopeiaObject):
    dto_type = cassiopeia.type.dto.summoner.RunePage

    def __str__(self):
        return "Rune Page ({name})".format(name=self.name)

    def __iter__(self):
        return iter(self.runes)

    def __len__(self):
        return len(self.runes)

    def __getitem__(self, index):
        return self.runes[index]

    def __eq__(self, other):
github meraki-analytics / cassiopeia / cassiopeia / type / dto / team.py View on Github external
def _sa_bind_team_stat_detail():
    global TeamStatDetail

    @cassiopeia.type.core.common.inheritdocs
    class TeamStatDetail(TeamStatDetail, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "TeamStatDetail"
        averageGamesPlayed = sqlalchemy.Column(sqlalchemy.Integer)
        losses = sqlalchemy.Column(sqlalchemy.Integer)
        teamStatType = sqlalchemy.Column(sqlalchemy.String(30))
        wins = sqlalchemy.Column(sqlalchemy.Integer)
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        _team_id = sqlalchemy.Column(sqlalchemy.String(50), sqlalchemy.ForeignKey("Team.fullId", ondelete="CASCADE"))
github meraki-analytics / cassiopeia / cassiopeia / core / summonerapi.py View on Github external
def __get_rune_pages_by_id(ids):
    pages = cassiopeia.core.requests.call_with_ensured_size(cassiopeia.dto.summonerapi.get_summoner_runes, 40, ids)

    # Load required data if loading policy is eager
    if cassiopeia.core.requests.load_policy is cassiopeia.type.core.common.LoadPolicy.eager:
        rune_ids = set()
        for page in pages.values():
            rune_ids |= page.rune_ids
        cassiopeia.riotapi.get_runes() if rune_ids else None

    if not isinstance(ids, list):
        return [cassiopeia.type.core.summoner.RunePage(page) for page in pages[str(ids)].pages]
    else:
        return [[cassiopeia.type.core.summoner.RunePage(page) for page in pages[str(id_)].pages] for id_ in ids]
github meraki-analytics / cassiopeia / cassiopeia / core / requests.py View on Github external
import cassiopeia.type.core.common
import cassiopeia.type.api.store

load_policy = cassiopeia.type.core.common.LoadPolicy.eager
data_store = cassiopeia.type.api.store.Cache()


def call_with_ensured_size(method, max_size, arg):
    """
    Breaks a list of arguments up into chunks of a maximum size and calls the given method on each chunk

    Args:
        method (function): the method to call
        max_size (int): the maximum number of arguments to include in a single call
        arg (any | list): the arguments to split up

    Returns:
        list | dict: the combined results of the function calls on each chunk
    """
    if not isinstance(arg, list) or len(arg) <= max_size:
        return method(arg)
github meraki-analytics / cassiopeia / cassiopeia / type / dto / tournament.py View on Github external
import cassiopeia.type.dto.common
import cassiopeia.type.core.common


if cassiopeia.type.dto.common.sqlalchemy_imported:
    import sqlalchemy
    import sqlalchemy.orm


@cassiopeia.type.core.common.inheritdocs
class TournamentCodeParameters(cassiopeia.type.dto.common.CassiopeiaParametersDto):
    """
    Args:
        teamSize (int): the team size of the game. Valid values are 1-5.
        spectatorType (str): the spectator type of the game. Valid values are NONE, LOBBYONLY, ALL.
        pickType (str): the pick type of the game. Valid values are BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT.
        mapType (str): the map type of the game. Valid values are SUMMONERS_RIFT, TWISTED_TREELINE, CRYSTAL_SCAR, and HOWLING_ABYSS.
        allowedSummonerIds (SummonerIdParams): optional list of participants in order to validate the players eligible to join the lobby. NOTE: We currently do not enforce participants at the team level, but rather the aggregate of teamOne and teamTwo. We may add the ability to enforce at the team level in the future.
        metadata (str): optional string that may contain any data in any format, if specified at all. Used to denote any custom information about the game.
    """
    def __init__(self, teamSize, spectatorType, pickType, mapType, allowedSummonerIds=None, metadata=""):