import yaml


def process_config(settings_file, campus):
    """Returns a dict of simple keyword configurations based on what
    was in the yaml file and the specific campus"""
    with open(settings_file, "r") as ymlfile:
        cfg = yaml.load(ymlfile, Loader=yaml.FullLoader)
    config = {}

    # Handle the settings based on the complex/standard switch
    if campus in cfg["use_complex"]:
        config["award_fields"] = cfg["award_fields"]["Complex"]
        config["award_sort"] = cfg["award_sort"]["Complex"]
    else:
        config["award_fields"] = cfg["award_fields"]["Standard"]
        config["award_sort"] = cfg["award_sort"]["Standard"]

    # For campus switches that modify "standard"
    for key in [
        "app_status_to_include",
        "efc_tab_name",
        "award_tab_name",
        "efc_header_row",
        "award_header_row",
        "decision_tab_name",
        "decision_options_tab_name",
        "decision_options_header_row",
        "decision_header_row",
        "decision_defaults",
        "report_award_sorts",
        "report_student_sorts",
    ]:
        if campus in cfg[key]:
            config[key] = cfg[key][campus]
        else:
            config[key] = cfg[key]["Standard"]

    # For straight reads:
    for key in [
        "output_folder",
        "report_filename",
        "report_folder",
        "excel_formats",
        "live_backup_folder",
        "live_backup_prefix",
        "drive_folder",
        "live_archive_folder",
        "campus_list",
        "live_award_fields",
        "file_stem",
        "efc_tab_fields",
        "app_fields",
        "roster_fields",
        "live_efc_fields",
        "report_award_fields",
        "report_award_formats",
        "decision_option_fields",
        "live_decision_fields",
        "report_student_fields",
        "summary_settings",
    ]:
        config[key] = cfg[key]

    for input_key in [
        "key_file",
        "current_applications",
        "current_roster",
        "strategies",
        "targets",
        "colleges",
        "acttosat",
        "bump_list",
        "ambitious_pp",
    ]:
        config[input_key] = cfg["inputs"][input_key]

    return config