def localconf(this, attribute='Meta', *args, **kw): ''' Load local configuration from `attribute` on `this` class and its base classes (plus any custom configuration). ''' return (lazyknife(this).mro().attrs(attribute).traverse().attrs('maps') .merge().params(*args, **kw).invoke('update').reverse().mapping() .wrap(frozenstuf).get())
def _load(self, destination, conf): # load configuration if isstring(conf): # load import conf = lazyimport(conf) if isinstance(conf, _BaseFactory): # load configuration from factory destination.update(i for i in conf) elif isclass(conf): # load configuration from class newconf = {} xpartmap( lambda x, y: x({y.pop('classname', 'options'): y}), iter(lazyknife(conf).traverse().attrs('maps').merge()), newconf.update, ) destination.update(newconf)