Module trase.tools.pcs.commodities.retrieve

Functions

def check_commodity_sequence(commodity_id_1: int, commodity_id_2: int, cur=None) ‑> bool

Return whether commodity_2 can be derived from commodity_1.

commodity_1 – commodity name 1 commodity_2 – commodity name 2

Keyword arguments: cur – Trase database cursor object

def get_commodity_data(commodity_id: int, cur=None) ‑> Tuple[int, str]
def get_commodity_descendants(commodity_id: int, cur=None) ‑> List[int]

Return commodity descendant ids from commodity id.

commodity_id – 'commodities.id' in Trase database

Keyword arguments: cur – Trase database cursor object

def get_commodity_equivalence_factors(commodity_identifiers: Iterable[str], trase_ids: Iterable[str], year: int, commodity_equivalence_group: str = None, cur=None)
def get_commodity_id(commodity_name: str, cur=None) ‑> int

Return commodity id from name.

commodity_name – commodity name

Keyword arguments: cur – Trase database cursor object

def get_commodity_name(commodity_id: int, cur=None) ‑> str

Return commodity name from id.

commodity_id – 'commodities.id' in Trase database

Keyword arguments: cur – Core database cursor object

def get_commodity_parent_id(commodity_id: int, ultimate=True, cur=None) ‑> int

Return commodity parent id from commodity id.

commodity_id – 'commodities.id' in Trase database

Keyword arguments: cur – Trase database cursor object

def get_commodity_parent_ids(commodity_id: int, cur=None) ‑> List[int]
def get_commodity_relatives(commodity_id: int, cur=None) ‑> List[int]

Return list of all commodities related to one commodity from commodity id.

commodity_id – 'commodities.id' in Trase database

Keyword arguments: cur – Trase database cursor object

def get_commodity_tree(commodity_id: int, cur=None) ‑> Dict[int, List[int]]

Return dictionary of commodity ids per level, with raw commodity at level 0.

commodity_id – 'commodities.id' in Trase database

Keyword arguments: cur – Trase database cursor object