Skip to content

Hazards

albert.collections.hazards.HazardsCollection

HazardsCollection(*, session: AlbertSession)

Bases: BaseCollection

Collection for fetching hazard symbols and statements.

Methods:

Name Description
get_symbols

Fetch the list of hazard symbols.

get_statements

Fetch the list of hazard statements.

Attributes:

Name Type Description
base_path
Source code in src/albert/collections/hazards.py
def __init__(self, *, session: AlbertSession):
    super().__init__(session=session)
    self.base_path = f"/api/{self._api_version}/static"

base_path

base_path = f'/api/{_api_version}/static'

get_symbols

get_symbols() -> list[HazardSymbol]

Fetch the list of hazard symbols.

Source code in src/albert/collections/hazards.py
@validate_call
def get_symbols(self) -> list[HazardSymbol]:
    """Fetch the list of hazard symbols."""

    response = self.session.get(f"{self.base_path}/hazardsymbols")
    response = response.json()
    symbols = response.get("HazardSymbols", []) if isinstance(response, dict) else []
    return [HazardSymbol(**symbol) for symbol in symbols]

get_statements

get_statements() -> list[HazardStatement]

Fetch the list of hazard statements.

Source code in src/albert/collections/hazards.py
@validate_call
def get_statements(self) -> list[HazardStatement]:
    """Fetch the list of hazard statements."""

    response = self.session.get(f"{self.base_path}/hazardstatements")
    response = response.json()
    return [HazardStatement(**item) for item in response]