def parse_parameter(cls, parameter) -> dict: """ Override the base method to add more steps. """ row = super().parse_parameter(parameter) # Combine the 'database' and 'code' fields of the parameter into a 'key' row["key"] = (parameter.database, parameter.code) act = bw.get_activity(row["key"]) row["product"] = act.get("reference product") or act.get("name") row["activity"] = act.get("name") row["location"] = act.get("location", "unknown") # Replace the namedtuple with the actual ActivityParameter row["parameter"] = ActivityParameter.get_by_id(parameter.id) return row
def parse_parameter(cls, parameter) -> dict: """ Override the base method to add more steps. """ row = super().parse_parameter(parameter) # Combine the 'database' and 'code' fields of the parameter into a 'key' row["key"] = (parameter.database, parameter.code) try: act = bw.get_activity(row["key"]) except: # Can occur if an activity parameter exists for a removed activity. print("Activity {} no longer exists, removing parameter.".format(row["key"])) signals.clear_activity_parameter.emit( parameter.database, parameter.code, parameter.group ) return {} row["product"] = act.get("reference product") or act.get("name") row["activity"] = act.get("name") row["location"] = act.get("location", "unknown") # Replace the namedtuple with the actual ActivityParameter row["parameter"] = ActivityParameter.get_by_id(parameter.id) return row