API Documentation¶
Documentation of statscraper’s public API.
Main Interface¶
-
class
statscraper.BaseScraper(*args, **kwargs)¶ The base class for scrapers.
-
children¶ Former, misleading name for descendants.
-
descendants¶ Recursively return every dataset below current item.
-
fetch(query=None, **kwargs)¶ Let the current item fetch it’s data.
-
items¶ ItemList of collections or datasets at the current position.
None will be returned in case of no further levels
-
move_to(id_)¶ Select a child item by id (str), reference or index.
-
move_to_top()¶ Move to root item.
-
move_up()¶ Move up one level in the hierarchy, unless already on top.
-
classmethod
on(hook)¶ Hook decorator.
-
parent¶ Return the item above the current, if any.
-
path¶ All named collections above, including the current, but not root.
-
-
class
statscraper.BaseScraperList¶ Lists of dimensions, values, etc all inherit this class for some common convenience methods, such as get_by_label()
-
get(key)¶ Provide alias for bracket notation.
-
-
class
statscraper.BaseScraperObject¶ Objects like items, dimensions, values etc all inherit this class. BaseScraperObjects are typicalliy stored in a BaseScraperList.
-
class
statscraper.Collection(id_, label=None, blob=None)¶ A collection can contain collection of datasets.
Lorem ipsum lorem lorem ipsum lorem. Dummy text.
Basic Usage:
>>> from statscraper import Collection >>> c = Collection() <class 'statscraper.base_scraper.Collection'>
-
class
statscraper.Dataset(id_, label=None, blob=None)¶ A dataset. Can be empty.
-
class
statscraper.Dimension(id_=None, label=None, allowed_values=None, datatype=None, dialect=None, domain=None)¶ A dimension in a dataset.
-
class
statscraper.DimensionList¶ A one dimensional list of dimensions.
-
class
statscraper.DimensionValue(value, dimension, label=None)¶ The value for a dimension inside a Resultset.
-
class
statscraper.Item(id_, label=None, blob=None)¶ Common base class for collections and datasets.
-
class
statscraper.Result(value, dimensions={})¶ A “row” in a result.
A result contains a numerical value, and optionally a set of dimensions with values.
-
class
statscraper.ResultSet¶ The result of a dataset query.
This is essentially a list of Result objects.
-
class
statscraper.ValueList¶ A list of dimension values.
allowed_values uses this class, to allow checking membership.
Exceptions¶
-
class
statscraper.exceptions.DatasetNotInView¶ Tried to operate on a dataset that is not visible.
This can be raised by a scraper if the cursor needs to move before inspecting an item.
-
class
statscraper.exceptions.InvalidData¶ The scraper encountered some invalid data.
-
class
statscraper.exceptions.InvalidID¶ This string is not allowed as an id at this point. Note: Inherits from Exception instead of StandardError for Python3.x compatibility reasons.
-
class
statscraper.exceptions.NoSuchDatatype¶ No datatype with that id.
-
class
statscraper.exceptions.NoSuchItem¶ No such Collection or Dataset.