pdg.utils module
Utilities for PDG API.
- pdg.utils.base_id(pdgid: str) str[source]
Get normalized base part of PDG Identifier.
Equivalent to calling
parse_id()and discarding the edition.- Parameters:
pdgid – String representation of a PDG Identifier.
- pdg.utils.get_linked_ids(api: PdgApi, table_name: str, src_col: str, src_id: int, dest_col: str = 'id') Iterator[int][source]
Get an iterator over internal links in a specified table.
Note
dest_col is assumed to be an ID column (i.e. an int).
- Parameters:
table_name – Name of the table in the SQLite file.
src_col – The column in which to search for the src_id.
src_id – The value (in the src_col column) corresponding to the “source” rows.
dest_col – The column containing the IDs of the “destination” rows.
- Returns:
The values of the dest_col column for all rows in which the src_col column is equal to src_id.
- pdg.utils.get_row_data(api: PdgApi, table_name: str, row_id: int) dict[source]
Get a dict built from a specified table row.
- Parameters:
api – API object for retrieving data.
table_name – Name of the table in the SQLite file.
row_id – Value of the id column (i.e. the primary key) to look up.
- pdg.utils.make_id(baseid: str, edition: str | None = None) str[source]
Get normalized full PDG Identifier, possibly including edition.
- Parameters:
baseid – String representation of a PDG Identifier, assumed not to specify an edition.
edition – Optional edition.
- Returns:
Normalized base part of identifier, along with edition (if specified), separated by a slash.
- pdg.utils.parse_id(pdgid: str) Tuple[str, str | None][source]
Parse and normalize a PDG Identifier.
- Parameters:
pdgid – String representation of a PDG Identifier.
- Returns:
Tuple of the normalized PDG Identifier (capitalized and without edition) and the edition (or None if the edition was unspecified in pdgid).