# Path: onix/scrapers.py
# def get_commit_from_timestamp(timestamp):
# def _write(data, destination_filename):
# def _scrape(url, entry, commit=None, destination_filename=None):
# def scrape_battle_formats_data(commit=None):
# def scrape_battle_pokedex(commit=None):
# def scrape_battle_aliases(commit=None):
# def scrape_battle_items(commit=None):
# def scrape_battle_movedex(commit=None):
# def scrape_formats(commit=None):


import datetime
import json
import onix.utilities as ut
from future.utils import iteritems
from onix import scrapers
    Raises:
        ResourceMissingError: if a required resource is missing from the
            context
    """

    for resource in resources:
        if hasattr(context, resource):
            if getattr(context, resource) is not None:
                continue
        raise ResourceMissingError(resource)


def _get_context(commit, force_refresh):
    psdata = dict(aliases=None, formats=None, formats_data=None, items=None,
                  moves=None, pokedex=None)

    if not force_refresh:

        folder = '.psdata/'
        if commit:
            folder += '{}'.format(commit)

        for resource in psdata.keys():
            try:
                psdata[resource] = json.load(open('{0}/{1}.json'
                                                  .format(folder, resource)))
            except IOError:
                pass

    if psdata['aliases'] is None:

# Path: onix/scrapers.py
# def get_commit_from_timestamp(timestamp):
# def _write(data, destination_filename):
# def _scrape(url, entry, commit=None, destination_filename=None):
# def scrape_battle_formats_data(commit=None):
# def scrape_battle_pokedex(commit=None):
# def scrape_battle_aliases(commit=None):
# def scrape_battle_items(commit=None):
# def scrape_battle_movedex(commit=None):
# def scrape_formats(commit=None):


# Path: onix/contexts.py
import datetime
import json
import onix.utilities as ut
from future.utils import iteritems
from onix import scrapers

    Raises:
        ResourceMissingError: if a required resource is missing from the
            context
    """

    for resource in resources:
        if hasattr(context, resource):
            if getattr(context, resource) is not None:
                continue
        raise ResourceMissingError(resource)


def _get_context(commit, force_refresh):
    psdata = dict(aliases=None, formats=None, formats_data=None, items=None,
                  moves=None, pokedex=None)

    if not force_refresh:

        folder = '.psdata/'
        if commit:
            folder += '{}'.format(commit)

        for resource in psdata.keys():
            try:
                psdata[resource] = json.load(open('{0}/{1}.json'
                                                  .format(folder, resource)))
            except IOError:
                pass

    if psdata['aliases'] is None:

        psdata['aliases'] = scrapers.scrape_battle_aliases(commit=commit)