import yaml
import six


def get_file_configuration(configuration_schema, config_content):
    """Get configuration, based on the configuration file.

    Args:
        configuration_schema (dict): a match between each target option to its
            sources.
        config_content (str): content of the configuration file in YAML format.

    Returns:
        dict: a match between each target option to the given value.
    """
    yaml_configuration = yaml.safe_load(config_content)
    if "rotest" not in yaml_configuration:
        return {}

    yaml_configuration = yaml_configuration["rotest"]

    configuration = {}
    for target, option in six.iteritems(configuration_schema):
        for config_file_option in option.config_file_options:
            if config_file_option in yaml_configuration:
                configuration[target] = yaml_configuration[config_file_option]
                break

    return configuration