def init_pattern_attributes(): """ Add all the attributes from the default modifier dictionary to the remote database """ # get the attributes from the remote data = self.get("pattern_attributes", {}) pattern_attributes = {} # for every pattern in the pattern dict for pt_name, pt_class in Patterns.items(): remote_att = {} # get the local modifier dictionary local_att = pt_class(handler=None, rate=1, pixels=1).modifiers # if there are none, then set to NA if len(local_att) == 0: pattern_attributes[pt_name] = "NA" continue # get the remote attributes try: remote_att = data[pt_name] except KeyError: if len(local_att) > 0: fire_logger.warning(f"Patter '{pt_name}' not found in pattern dict") pattern_attributes[pt_name] = {} # for every attribute for att_name, modifier in local_att.items(): # generate a dictionary with the corresponding values att_dict = dict( value=modifier.value, name=modifier.name, type=modifier.type.__name__ ) if modifier.type == list: att_dict['options'] = modifier.options # try to override the default value with the one from the db try: att_dict['value'] = remote_att[att_name]['value'] except (TypeError, KeyError): pass # set the value pattern_attributes[pt_name][att_name] = att_dict # update the database self.root.update(dict(pattern_attributes=pattern_attributes)) return pattern_attributes