import os from src.utils.data import load_json, save_json AUTHORS_TAXONOMY = os.path.join("data", "authors_taxonomy.json") AUTHORS_FILTER = os.path.join("data", "authors_filter.json") DRAFT_CATEGORIES_TAXONOMY = os.path.join("data", "draftcat_taxonomy.json") DRAFT_CATEGORIES_FILTER = os.path.join("data", "draftcat_taxonomy_filter.json") def get_authors(taxonomy: dict) -> dict: countries = taxonomy["Members"]["Countries"] associations = taxonomy["Members"][ "International and Regional State Associations" ] # noqa: E501 intergovernmental_negotiations = taxonomy[ "Intergovernmental Negotiation Committee" ] # noqa: E501 observers = taxonomy["Observers and Other Participants"] # noqa: E501 return { "Members - Countries": countries, "Members - International and Regional State Associations": associations, # noqa: E501 "Intergovernmental Negotiation Committee": intergovernmental_negotiations, # noqa: E501 "Observers and Other Participants": observers, } def get_draftcategories(taxonomy: dict) -> dict: taxonomy_filter = {} for draft_part, part_values in taxonomy.items(): part = draft_part temp_values = [] for part_name, part_value in part_values.items(): temp_values.append(part_value) taxonomy_filter[part] = temp_values return taxonomy_filter if __name__ == "__main__": authors_taxonomy = load_json(AUTHORS_TAXONOMY) authors_filter = get_authors(authors_taxonomy) save_json(file_path=AUTHORS_FILTER, data=authors_filter) draft_categories_taxonomy = load_json(DRAFT_CATEGORIES_TAXONOMY) draft_categories_filter = get_draftcategories(draft_categories_taxonomy) save_json(file_path=DRAFT_CATEGORIES_FILTER, data=draft_categories_filter)