fdutils/config/__init__.py
def parse_yaml(config_file_path, base_name='bases', safe=True, replace_list=True):
    """     recursively retrieves configuration from yaml files

    Args:
        config_file_path: starting yaml config file
        base_name: attribute name to use to find parents
        safe: use yaml.safe_load
        replace_list: if True values that are list are replace if false, values are appended if missing

    Returns:

    """
    config_folder, config_file = os.path.split(config_file_path)

    loader = yaml.safe_load if safe else yaml.load

    def deep_update(source, overrides):
        """Update a nested dictionary or similar mapping.

        Modify ``source`` in place.
        """
        for key, value in overrides.items():
            if value and isinstance(value, collections.Mapping):
                source[key] = deep_update(source.get(key, {}), value)
            elif not replace_list and value and isinstance(value, collections.MutableSequence):
                if key not in source:
                    source[key] = []
                deletions = []
                for v in value:
                    if v.startswith('-'):
                        deletions.append(v[1:])
                    elif v not in source[key]:
                        source[key].append(v)
                source[key] = [s for s in source[key] if s not in deletions]
            else:
                source[key] = value
        return source

    def load_yaml(path):
        with open(path) as f:
            yfile = f.read()

        problems = get_yaml_syntax_error(yfile)
        if problems:
            msg = ('\n' + '#' * 80 + '\n\nYour YAML configuration file {} has problems: \n\n'.format(config_file_path) +
                  problems)
            raise Exception(msg)

        return loader(yfile)

    cfg = load_yaml(config_file_path)

    visited_parents = []
    parents = cfg.pop(base_name, [])

    while parents:
        new_parents = []
        visited_parents.extend(parents)
        for parent in parents:
            parent_config = load_yaml(get_file_to_open(config_folder, parent))
            new_parents.extend(p for p in parent_config.pop(base_name, []) if p not in visited_parents)
            cfg = deep_update(parent_config, cfg)
        parents = new_parents

    return cfg
     recursively retrieves configuration from yaml files

    Args:
        config_file_path: starting yaml config file
        base_name: attribute name to use to find parents
        safe: use yaml.safe_load
        replace_list: if True values that are list are replace if false, values are appended if missing

    Returns:

    
recursively retrieves configuration from yaml files
recursively retrieves configuration from yaml files
def parse_yaml(config_file_path, base_name='bases', safe=True, replace_list=True):
    config_folder, config_file = os.path.split(config_file_path)
    loader = yaml.safe_load if safe else yaml.load
    def deep_update(source, overrides):
        for key, value in overrides.items():
            if value and isinstance(value, collections.Mapping):
                source[key] = deep_update(source.get(key, {}), value)
            elif not replace_list and value and isinstance(value, collections.MutableSequence):
                if key not in source:
                    source[key] = []
                deletions = []
                for v in value:
                    if v.startswith('-'):
                        deletions.append(v[1:])
                    elif v not in source[key]:
                        source[key].append(v)
                source[key] = [s for s in source[key] if s not in deletions]
            else:
                source[key] = value
        return source
    def load_yaml(path):
        with open(path) as f:
            yfile = f.read()
        problems = get_yaml_syntax_error(yfile)
        if problems:
            msg = ('\n' + '#' * 80 + '\n\nYour YAML configuration file {} has problems: \n\n'.format(config_file_path) +
                  problems)
            raise Exception(msg)
        return loader(yfile)
    cfg = load_yaml(config_file_path)
    visited_parents = []
    parents = cfg.pop(base_name, [])
    while parents:
        new_parents = []
        visited_parents.extend(parents)
        for parent in parents:
            parent_config = load_yaml(get_file_to_open(config_folder, parent))
            new_parents.extend(p for p in parent_config.pop(base_name, []) if p not in visited_parents)
            cfg = deep_update(parent_config, cfg)
        parents = new_parents
    return cfg
def parse_yaml ( config_file_path , base_name = 'bases' , safe = True , replace_list = True ) : config_folder , config_file = os . path . split ( config_file_path ) loader = yaml . safe_load if safe else yaml . load def deep_update ( source , overrides ) : """Update a nested dictionary or similar mapping.

        Modify ``source`` in place.
        """ for key , value in overrides . items ( ) : if value and isinstance ( value , collections . Mapping ) : source [ key ] = deep_update ( source . get ( key , { } ) , value ) elif not replace_list and value and isinstance ( value , collections . MutableSequence ) : if key not in source : source [ key ] = [ ] deletions = [ ] for v in value : if v . startswith ( '-' ) : deletions . append ( v [ 1 : ] ) elif v not in source [ key ] : source [ key ] . append ( v ) source [ key ] = [ s for s in source [ key ] if s not in deletions ] else : source [ key ] = value return source def load_yaml ( path ) : with open ( path ) as f : yfile = f . read ( ) problems = get_yaml_syntax_error ( yfile ) if problems : msg = ( '\n' + '#' * 80 + '\n\nYour YAML configuration file {} has problems: \n\n' . format ( config_file_path ) + problems ) raise Exception ( msg ) return loader ( yfile ) cfg = load_yaml ( config_file_path ) visited_parents = [ ] parents = cfg . pop ( base_name , [ ] ) while parents : new_parents = [ ] visited_parents . extend ( parents ) for parent in parents : parent_config = load_yaml ( get_file_to_open ( config_folder , parent ) ) new_parents . extend ( p for p in parent_config . pop ( base_name , [ ] ) if p not in visited_parents ) cfg = deep_update ( parent_config , cfg ) parents = new_parents return cfg
recursively retrieves configuration from yaml files
recursively retrieves configuration from yaml files
"""     recursively retrieves configuration from yaml files

    Args:
        config_file_path: starting yaml config file
        base_name: attribute name to use to find parents
        safe: use yaml.safe_load
        replace_list: if True values that are list are replace if false, values are appended if missing

    Returns:

    """ """Update a nested dictionary or similar mapping.

        Modify ``source`` in place.
        """
None
config_file_path
starting yaml config file
starting yaml config file
base_name
attribute name to use to find parents
attribute name to use to find parents
safe
None
replace_list
if True values that are list are replace if false, values are appended if missing
if True values that are list are replace if false values are appended if missing