appabuild.database.bw_databases#

This module contains classes and functions to interact with databases imported in Brightway project.

Classes#

BwDatabase

Interacts with the database with corresponding name imported in Brightway project.

Module Contents#

class appabuild.database.bw_databases.BwDatabase#

Bases: pydantic.BaseModel

Interacts with the database with corresponding name imported in Brightway project.

resolve_activity_identifier(unresolved_activity_identifier: appabuild.database.serialized_data.ActivityIdentifier) appabuild.database.serialized_data.ActivityIdentifier#

Resolve an unresolved activity identifier, i.e. find uuid of an activity identified by a set of regexes. Raise an error if more or less than one activity is found. :param unresolved_activity_identifier: activity identified by a set of regexes. Must be of the same database. :return: resolved ActivityIdentifier, i.e. with uuid defined.

search_activity(regexes: dict, must_find_only_one: bool | None = False) appabuild.database.serialized_data.ActivityIdentifier | List[appabuild.database.serialized_data.ActivityIdentifier]#

Search an activity in database with a set of regexes on any activities’ field. :param regexes: key is the field and value the regex to match. :param must_find_only_one: if True, will raise an exception if the quantity of matching activities is different than one. :return: ActivityIdentifier, or list of ActivityIdentifier of matching activities.

property database#

Brightway database object :return:

name: str#