def recalculate_database_parameters(self, database: str, global_params: dict = None ) -> Optional[dict]: new_values = self.get_altered_values(database) if global_params is None: global_params = {} data = DatabaseParameter.load(database) if not data: return for name, amount in new_values.items(): data[name]["amount"] = amount new_symbols = get_new_symbols(data.values(), set(data)) missing = new_symbols.difference(global_params) if missing: raise MissingName( "The following variables aren't defined:\n{}".format( "|".join(missing))) glo = self._static(global_params, needed=new_symbols) if new_symbols else None ParameterSet(data, glo).evaluate_and_set_amount_field() return self._prune_result_data(data)
def __init__(self): self._project_params = ProjectParameter.load() self._db_params = { p.database: DatabaseParameter.load(p.database) for p in DatabaseParameter.select(DatabaseParameter.database).distinct() } self._act_params = { p.group: ActivityParameter.load(p.group) for p in ActivityParameter.select(ActivityParameter.group).distinct() } self._distinct_act_params = [ p for p in (ActivityParameter .select(ActivityParameter.group, ActivityParameter.database) .distinct()) ] self._exc_params = [p for p in ParameterizedExchange.select()]