self.author_url = '' self.code_editor = '' self.json_indent = 2 self._a2 = a2 self._defaults = { 'author_name': os.getenv('USERNAME'), 'author_url': '', 'code_editor': '', 'json_indent': 2, 'loglevel_debug': False} self.get() def get(self): settings = self._a2.db.get_changes('dev_settings', self._defaults) self._set_attrs(settings) return settings def _set_attrs(self, settings): for key, value in settings.items(): setattr(self, key, value) def set(self, these): self._a2.db.set_changes('dev_settings', these, self._defaults) self._set_attrs(these) if __name__ == '__main__': import a2app a2app.main()
if typ is not None: if not isinstance(value, typ): if default is None: value = typ() else: log.error('Fetched wrong type for attr_name %s: %s' % (attr_name, value)) value = default return value def assemble_settings(module_key, cfg_dict, db_dict, module_path=None): for cfg in cfg_dict: # get configs named db entry of module or None user_cfg = a2core.A2Obj.inst().db.get(cfg.get('name'), module_key) # pass if there is an 'enabled' entry and it's False if not get_cfg_value(cfg, user_cfg, 'enabled', default=True): continue element_get_settings = get_a2element_object('get_settings', cfg['typ'], module_path) if element_get_settings is not None: element_get_settings(module_key, cfg, db_dict, user_cfg) if __name__ == '__main__': import a2app a2app.main()