def extract_conf_from(mod, conf=ModuleConfig(CONF_SPEC), depth=0, max_depth=2):
    """recursively extract keys from module or object
    by passed config scheme
    """

    # extract config keys from module or object
    for key, default_value in six.iteritems(conf):
        conf[key] = _get_key_from_module(mod, key, default_value)

    # support for recursive dependecies
    try:
        filtered_apps = [app for app in conf['apps'] if app not in BLACKLIST]
    except TypeError:
        pass
    except Exception as e:
        warnings.warn('Error %s during loading %s' % (e, conf['apps']))

    for app in filtered_apps:
        try:
            app_module = import_module(app)
            if app_module != mod:
                app_module = _get_correct_module(app_module)
                if depth < max_depth:
                    mod_conf = extract_conf_from(app_module, depth=depth+1)
                    for k, v in six.iteritems(mod_conf):
                        # prevent config duplicity
                        # skip config merge
                        if k == 'config':
                            continue
                        if isinstance(v, dict):
                            conf[k].update(v)
                        elif isinstance(v, (list, tuple)):
                            conf[k] = merge(conf[k], v)
        except Exception as e:
            pass  # swallow, but maybe log for info what happens
    return conf
def extract_conf_from ( mod , conf = ModuleConfig ( CONF_SPEC ) , depth = 0 , max_depth = 2 ) : for key , default_value in six . iteritems ( conf ) : conf [ key ] = _get_key_from_module ( mod , key , default_value ) try : filtered_apps = [ app for app in conf [ 'apps' ] if app not in BLACKLIST ] except TypeError : pass except Exception as e : warnings . warn ( 'Error %s during loading %s' % ( e , conf [ 'apps' ] ) ) for app in filtered_apps : try : app_module = import_module ( app ) if app_module != mod : app_module = _get_correct_module ( app_module ) if depth < max_depth : mod_conf = extract_conf_from ( app_module , depth = depth + 1 ) for k , v in six . iteritems ( mod_conf ) : if k == 'config' : continue if isinstance ( v , dict ) : conf [ k ] . update ( v ) elif isinstance ( v , ( list , tuple ) ) : conf [ k ] = merge ( conf [ k ] , v ) except Exception as e : pass return conf
recursively extract keys from module or object
    by passed config scheme