import configparser


def get_default_choice_index_from_config(config, section, option, choice_list, fallback=1):
    """Get index + 1 of the current choice value from cong, replacing with fallback if not found"""
    try:
        config_val = config.get(section, option)
        return [i for i, x in enumerate(choice_list) if "name" in x and x["name"] == config_val][
            0
        ] + 1
    except (IndexError, configparser.NoSectionError, configparser.NoOptionError):
        return fallback