API

Favourite module

companion.favourite.favourite_add(add, cfg, file)

Adds player ID to the favourites in the config file.

Parameters:
  • add – Player ID to be added.
  • cfg – ConfigParser instance with loaded actual config file.
  • file – Path to the config file.
companion.favourite.favourite_remove(remove, cfg, file)

Removes player ID from the favourites in the config file.

Parameters:
  • add – Player ID to be removed.
  • cfg – ConfigParser instance with loaded actual config file.
  • file – Path to the config file.

Helpers module

class companion.helpers.MutuallyExclusiveOption(*args, **kwargs)
handle_parse_result(ctx, opts, args)
companion.helpers.filter_by_multiple_keys(f, array)

Base function used for the filtering.

Parameters:
  • f – Function used for the filtering.
  • array – Array of dicts to be filtered.
Returns:

Filtered array.

companion.helpers.filter_eq(keys, value, array)

Filters array of dicts by equality of given value with one of the define keys.

Parameters:
  • keys – Keys used for the comparison.
  • value – Value used for the comparison.
  • array – Array of dicts to be filtered.
Returns:

Filtered array of dicts.

companion.helpers.filter_substr(keys, value, array)

Filters array of dicts by finding substring under one of the given keys.

Parameters:
  • keys – Keys used for the comparison.
  • value – Value used for the comparison.
  • array – Array of dicts to be filtered.
Returns:

Filtered array of dicts.

companion.helpers.get_response_json(endpoint, session=<requests.sessions.Session object>)

Sends request to the API.

Parameters:
  • endpoint – Endpoint to be used for the request.
  • session – Session to be used for HTTP comm.
Returns:

JSON object with response.

Heroes module

companion.heroes.endpoint(name, best, meta, counter)

Defines endpoint to use based on parameters.

Parameters:
  • name – Name of the hero.
  • best – Boolean whether to use endpoint for best heroes.
  • meta – Boolean whether to use endpoint for meta heroes.
  • meta – Boolean whether to use endpoint for counter heroes.
Returns:

Endpoint string.

companion.heroes.primary(attr)

Returns attribute name based on shortcut.

Parameters:attr – Attribute shortcut.
Returns:Attribute name.
companion.heroes.print_heroes_best(data)

Prints best heroes data.

Parameters:data – Data to be printed.
companion.heroes.print_heroes_counter(data, id_)

Prints counter heroes data.

Parameters:
  • data – Data to be printed.
  • id – Player ID to be used for personalized counter heroes.
companion.heroes.print_heroes_meta(data)

Prints meta heroes data.

Parameters:data – Data to be printed.
companion.heroes.print_heroes_stats(data, name)

Prints heroes data.

Parameters:
  • data – Data to be printed.
  • name – Hero name.
companion.heroes.process_heroes(data, name, best, meta, counter, id_)

Processes data based on given parameters and prints data to stdout.

Parameters:
  • name – Name of the hero.
  • best – Boolean whether to process data as best heroes.
  • meta – Boolean whether to process data as meta heroes.
  • counter – Boolean whether to process data as counter heroes.
  • id – Player ID for personalized counter heroes.

Match module

class companion.match.Match(data, type)

Match entity holding important data for the match.

match_players_str(radiant)

Players of the match string representation.

matches_id()

Exact match string representation.

matches_live()

Live matches string representation.

matches_recent()

Recent matches string representation.

class companion.match.MatchType

Defines Match entity type.

EXACT = 3
LIVE = 2
RECENT = 1

Matches module

companion.matches.endpoint(id_, live)

Defines endpoint by given parameters.

Parameters:
  • id – Match ID.
  • live – Boolean whether to use live matches endpoint.
Returns:

Endpoint string.

companion.matches.process_matches(type, data, team=None, league=None)

Processes matches data by given parameters and prints to stdout.

Parameters:
  • type – MatchType for the processing.
  • data – Data to be processed.
  • team – Teams to be used for filtering.
  • league – League to be used for filtering.
companion.matches.validate_teams(ctx, param, value)

Validates given team parameters.

Parameters:value – Value to be validated.

MMR module

companion.mmr.print_mmr(data)

Prints MMR data to stdout.

Parameters:data – Data to be printed.
companion.mmr.print_mmr_country(data, country)

Prints MMR country data to stdout.

Parameters:
  • data – Data to be printed.
  • country – Country string to be used as a filter.
companion.mmr.print_mmr_rank(data)

Prints MMR ranks data to stdout.

Parameters:data – Data to be printed.
companion.mmr.process_mmr(data, ranks, country)

Processes MMR data and prints to stdout.

Parameters:
  • data – Data to be processed.
  • ranks – Boolean whether to process data as ranks distribution.
  • country – Country name for country MMR distribution.

Player module

class companion.player.Player(data_general, data_matches, data_heroes, data_totals, data_peers)

Player entity holding important data for the player.

prefers()

Defines which side player prefers.

Returns:Side name.

PlayerFriend module

class companion.player_friend.PlayerFriend(data)

Entity holding important data for player’s best friends data.

PlayerHero module

class companion.player_hero.PlayerHero(data, best)

Entity holding important data for player’s heroes data.

best_hero_str()

Best hero representation.

scariest_hero_str()

Scariest hero representation.

PlayerMatch module

class companion.player_match.PlayerMatch(data)

Entity holding important data for player’s match.

hero()

Hero name string.

mode()

Game mode string.

skill()

Skill string.

status()

Game outcome string.

Players module

companion.players.best_heroes(id_)

Prints player’s best heroes representation to stdout.

Parameters:id – Player ID.
companion.players.load_player(id_)

Loads player’s data from remote.

Parameters:id – Player ID.
Returns:Player entity.
companion.players.player_id_is_ok(id_)

Checks if given player ID is valid.

Parameters:id – Player ID to be checked.
Returns:Boolean whether the ID is valid.
companion.players.players_favourite(favourites)

Prints player’s favourites players data to stdout.

Parameters:favourites – Dict of favourites.
companion.players.players_heroes(id_)

Gets player’s heroes data.

Parameters:id – Player ID.
Returns:JSON with player’s heroes data.
companion.players.players_id(id_)

Prints player’s data to stdout.

Parameters:id – Player ID.
companion.players.print_players(data)

Prints player’s data to stdout.

Parameters:data – Data to be printed.
companion.players.process_players(data, country, team, name)

Processes player’s data by given parameters and prints to stdout.

Parameters:
  • data – Data to be processed.
  • country – Country to be used as a filter.
  • team – Team to be used as a filter.
  • name – Name to be used as a filter.