Read and extends/creates configuration from yaml source.

    .. note::
        If exists, this method extends config with defaults,
        so it will not override existing values, merely add those,
        that were not defined already!

    :param pyramid.config.Configurator configurator: pyramid's app configurator
    :param list config_locations: list of yaml file locations
    :param list files: list of files to include from location

def config_defaults(
        configurator, config_locations, files=None):
    """
    Read and extends/creates configuration from yaml source.

    .. note::
        If exists, this method extends config with defaults,
        so it will not override existing values, merely add those,
        that were not defined already!

    :param pyramid.config.Configurator configurator: pyramid's app configurator
    :param list config_locations: list of yaml file locations
    :param list files: list of files to include from location
    """
    if files is None:
        files = ['config.yaml', 'config.yml']
    if not isinstance(config_locations, (list, tuple)):
        config_locations = config_locations.split(',')

    env = configurator.registry.settings.get('env', 'dev')

    file_paths = []
    for location in config_locations:
        path = _translate_config_path(location)
        current_files = files
        if os.path.isfile(path):
            path, current_files = os.path.split(path)
            current_files = [current_files]

        for config_path in [
                os.path.join(path, f)
                for f in _env_filenames(current_files, env)
        ]:
            if os.path.isfile(config_path):
                file_paths.append(config_path)

    config = ConfigManager(files=file_paths)

    # we could use this method both for creating and extending.
    # Hence the checks to not override
    if 'config' not in configurator.registry:
        configurator.registry['config'] = config
    else:
        config.merge(configurator.registry['config'])
        configurator.registry['config'] = config