Loads a config file, whether it is a yaml file or a .INI file.

    :param config_file_path: Path of the configuration file, used to infer the file format.
    :returns: Dictionary representation of the configuration file.

def load_config_file(config_file_path, config_file):
    """
    Loads a config file, whether it is a yaml file or a .INI file.

    :param config_file_path: Path of the configuration file, used to infer the file format.
    :returns: Dictionary representation of the configuration file.
    """

    if config_file_path.lower().endswith(".yaml"):
        return yaml.load(config_file)

    if any(config_file_path.lower().endswith(extension) for extension in INI_FILE_EXTENSIONS):
        return load_config_from_ini_file(config_file)

    # At this point we have to guess the format of the configuration file.
    try:
        return yaml.load(config_file)
    except yaml.YAMLError:
        pass

    try:
        return load_config_from_ini_file(config_file)
    except:
        pass

    raise Exception("Could not load configuration file!")