onix.scrapers module

This module contains utilities for creating resources and for generating unit tests

Functionality for pulling information from PS and converting to JSON

onix.scrapers.get_commit_from_timestamp(timestamp)[source]

Get the PS commit hash corresponding to the last commit to master as of the specified timestamp

Parameters:timestamp (datetime.datetime) – The date and time (in UTC) desired
Returns:The commit has correspond to the last commit to master as of the specified timestamp
Return type:str

Examples

>>> from datetime import datetime
>>> from onix.scrapers import get_commit_from_timestamp
>>> print(get_commit_from_timestamp(datetime(2016, 12, 1, 5, 0)))
841d4c9e135d07d7affb725bf42f81df376b2de1
onix.scrapers.scrape_battle_formats_data(commit=None)[source]

Grabs data including tier information for Pokemon. Useful for extracting banlists for the standard tiers.

Parameters:commit (str, optional) – if specified, will pull the version of the file as of the commit specified by this full hash.
Returns:the data encoded in formats-data.js. The keys are the species / forme names
Return type:dict

Examples

>>> from onix import scrapers
>>> commit = '5c14138b54dddf8bc034433eaef950a1c6eaf734'
>>> battle_formats = scrapers.scrape_battle_formats_data(commit=commit)
>>> print(battle_formats['bulbasaur']['tier'])
LC
onix.scrapers.scrape_battle_pokedex(commit=None)[source]

Grabs data including base stats, types and appearance-only form info, then does a little bit of post-processing to unlink Pokemon that cannot move between formes during battle (e.g.: Rotom-Wash)

Parameters:commit (str, optional) –

if specified, will pull the version of the file as of the commit specified by this full hash.

Note

In most cases, one shouldn’t need to use old versions of the Pokedex, as data very rarely gets overwritten or removed. If one is looking to pull information from a previous generation, use a mod, not an old commit.

Returns:the data encoded in pokedex.js. The keys are the species / forme names
Return type:dict

Examples

>>> from onix import scrapers
>>> pokedex = scrapers.scrape_battle_pokedex()
>>> print(pokedex['bulbasaur']['baseStats']['hp'])
45
onix.scrapers.scrape_battle_aliases(commit=None)[source]

Grabs Pokemon aliases.

Parameters:commit (str, optional) – if specified, will pull the version of the file as of the commit specified by this full hash.
Returns:the data encoded in aliases.js. The keys are the alternate names, the values are the correct names.
Return type:dict

Examples

>>> from onix import scrapers
>>> aliases = scrapers.scrape_battle_aliases()
>>> print(aliases['forry'])
Forretress
onix.scrapers.scrape_battle_items(commit=None)[source]

Grabs items. Used for determining mega evolutions and for pretty-print lookups.

Parameters:commit (str, optional) –

if specified, will pull the version of the file as of the commit specified by this full hash.

Note

In most cases, one shouldn’t need to use old versions of the Item dex, as data very rarely gets overwritten or removed. If one is looking to pull information from a previous generation, use a mod, not an old commit.

Returns:the data encoded in items.js
Return type:dict

Examples

>>> from onix import scrapers
>>> items = scrapers.scrape_battle_items()
>>> print(items['gardevoirite']['megaEvolves'])
Gardevoir
onix.scrapers.scrape_battle_movedex(commit=None)[source]

Grabs move metadata.

Parameters:commit (str, optional) –

if specified, will pull the version of the file as of the commit specified by this full hash.

Note

In most cases, one shouldn’t need to use old versions of the Move dex, as data very rarely gets overwritten or removed. If one is looking to pull information from a previous generation, use a mod, not an old commit.

Returns:the data encoded in moves.js
Return type:dict

Examples

>>> from onix import scrapers
>>> moves = scrapers.scrape_battle_movedex()
>>> print(moves['scald']['name'])
Scald
onix.scrapers.scrape_formats(commit=None)[source]

Grabs rulesets for the various metagames and saves it as formats.json. Useful for extracting, say, banlists for non-standard tiers. Does a bit of post-processing to transform the data from a list to a dict and to expand out any inherited rulesets

Parameters:commit (str, optional) – if specified, will pull the version of the file as of the commit specified by this full hash.
Returns:the data encoded in formats.js, post-processed for increased utility
Return type:dict

Examples

>>> from onix import scrapers
>>> commit = '5c14138b54dddf8bc034433eaef950a1c6eaf734'
>>> formats = scrapers.scrape_formats(commit=commit)
>>> print(formats['lc']['maxLevel'])
5