diff options
| author | diogo464 <[email protected]> | 2025-07-21 15:02:48 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-07-21 15:02:48 +0100 |
| commit | 8c8dabd0ed20679a2dad43a5c239f9fcfe1c1ad7 (patch) | |
| tree | 55abbcfbbff19efa3aaf6cf36540ac7651c54973 /extract-organizer | |
init
Diffstat (limited to 'extract-organizer')
| -rwxr-xr-x | extract-organizer | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/extract-organizer b/extract-organizer new file mode 100755 index 000000000..3739f4ead --- /dev/null +++ b/extract-organizer | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | import os | ||
| 3 | import sys | ||
| 4 | import json | ||
| 5 | |||
| 6 | ORGANIZER_XISTARCA = "xistarca" | ||
| 7 | ORGANIZER_WERUN = "werun" | ||
| 8 | ORGANIZER_HMS_SPORTS = "hms-sports" | ||
| 9 | ORGANIZER_CPA = "cpa" | ||
| 10 | ORGANIZER_TRILHO_PERDIDO = "trilho-perdido" | ||
| 11 | ORGANIZER_EVENT_SPORT = "event-sport" | ||
| 12 | ORGANIZER_RUN_PORTO = "run-porto" | ||
| 13 | ORGANIZER_BRAGANCA_GRANFONDO_BY_TREK="braganca-grafondo-by-trek" | ||
| 14 | ORGANIZER_VILA_FRANCA_DE_XIRA_LISBOA = "vila-franca-de-xira-lisboa" | ||
| 15 | ORGANIZER_SINTRA_LISBOA = "sintra-lisboa" | ||
| 16 | ORGANIZER_CAMARA_MUNICIPAL_DE_OEIRAS = "camara-municipal-de-oeiras" | ||
| 17 | ORGANIZER_MARCO_DE_CANAVESES_PORTO = "marco-de-canaveses-porto" | ||
| 18 | ORGANIZER_ESTADIO_UNIVERSITARIO_LISBOA = "estadio-universitario-lisboa" | ||
| 19 | ORGANIZER_CLUBE_DO_PESSOAL_AGUAS_DE_GAIA = "clube-do-pessoal-aguas-de-gaia" | ||
| 20 | ORGANIZER_AARAM = "aaram" | ||
| 21 | ORGANIZER_SANTA_CRUZTORRES_VEDRAS = "santa-cruztorres-vedras" | ||
| 22 | ORGANIZER_CLUBE_ASSOCIACAO_DESPORTIVA_E_RECREATIVA_DA_MATA = "clube-associacao-desportiva-e-recreativa-da-mata" | ||
| 23 | ORGANIZER_TURRES_EVENTS = "turres-events" | ||
| 24 | ORGANIZER_CAMARA_MUNICIPAL_DE_ESTREMOZ = "camara-municipal-de-estremoz" | ||
| 25 | ORGANIZER_GRUPO_DE_CULTURA_E_DESPORTO_DOS_BOMBEIROS_VOLUNTARIOS_DE_S_B_MESSINES = "grupo-de-cultura-e-desporto-dos-bombeiros-voluntarios-de-s-b-messines" | ||
| 26 | |||
| 27 | CLASS_TO_ORGANIZER = { | ||
| 28 | "event_organizer-xistarca": ORGANIZER_XISTARCA, | ||
| 29 | "event_organizer-we-run": ORGANIZER_WERUN, | ||
| 30 | "event_organizer-cpa": ORGANIZER_CPA, | ||
| 31 | "event_organizer-eventsport": ORGANIZER_EVENT_SPORT, | ||
| 32 | "event_organizer-trilho-perdido": ORGANIZER_TRILHO_PERDIDO, | ||
| 33 | "event_organizer-runporto": ORGANIZER_RUN_PORTO, | ||
| 34 | "event_organizer-hms-sports": ORGANIZER_HMS_SPORTS, | ||
| 35 | "event_organizer-vila-franca-de-xira-lisboa":ORGANIZER_VILA_FRANCA_DE_XIRA_LISBOA, | ||
| 36 | "event_organizer-braganca-granfondo-by-trek":ORGANIZER_BRAGANCA_GRANFONDO_BY_TREK, | ||
| 37 | "event_organizer-sintra-lisboa": ORGANIZER_SINTRA_LISBOA, | ||
| 38 | "event_organizer-camara-municipal-de-oeiras": ORGANIZER_CAMARA_MUNICIPAL_DE_OEIRAS, | ||
| 39 | "event_organizer-marco-de-canaveses-porto": ORGANIZER_MARCO_DE_CANAVESES_PORTO, | ||
| 40 | "event_organizer-estadio-universitario-lisboa": ORGANIZER_ESTADIO_UNIVERSITARIO_LISBOA, | ||
| 41 | "event_organizer-clube-do-pessoal-aguas-de-gaia": ORGANIZER_CLUBE_DO_PESSOAL_AGUAS_DE_GAIA, | ||
| 42 | "event_organizer-aaram": ORGANIZER_AARAM, | ||
| 43 | "event_organizer-santa-cruztorres-vedras": ORGANIZER_SANTA_CRUZTORRES_VEDRAS, | ||
| 44 | "event_organizer-clube-associacao-desportiva-e-recreativa-da-mata": ORGANIZER_CLUBE_ASSOCIACAO_DESPORTIVA_E_RECREATIVA_DA_MATA, | ||
| 45 | "event_organizer-turres-events": ORGANIZER_TURRES_EVENTS, | ||
| 46 | "event_organizer-camara-municipal-de-estremoz": ORGANIZER_CAMARA_MUNICIPAL_DE_ESTREMOZ, | ||
| 47 | "event_organizer-grupo-de-cultura-e-desporto-dos-bombeiros-voluntarios-de-s-b-messines": ORGANIZER_GRUPO_DE_CULTURA_E_DESPORTO_DOS_BOMBEIROS_VOLUNTARIOS_DE_S_B_MESSINES, | ||
| 48 | # ignored | ||
| 49 | "ajde_events": None, | ||
| 50 | "type-ajde_events": None, | ||
| 51 | "status-publish": None, | ||
| 52 | "has-post-thumbnail": None, | ||
| 53 | "hentry": None, | ||
| 54 | } | ||
| 55 | CLASS_IGNORE_PREFIXES = [ | ||
| 56 | "post-", | ||
| 57 | "event_location-", | ||
| 58 | "event_type-", | ||
| 59 | "event_type_2", | ||
| 60 | "event_type_3-sim", | ||
| 61 | "event_type_4-", | ||
| 62 | "event_type_5-", | ||
| 63 | ] | ||
| 64 | |||
| 65 | for slug in sys.argv[1:]: | ||
| 66 | data_path = os.path.join("events", slug, "data.json") | ||
| 67 | with open(data_path, "r") as f: | ||
| 68 | data = json.load(f) | ||
| 69 | classes = data["class_list"] | ||
| 70 | organizer = None | ||
| 71 | organizer_path = os.path.join("events", slug, "organizer") | ||
| 72 | for class_ in classes: | ||
| 73 | if any(class_.startswith(p) for p in CLASS_IGNORE_PREFIXES): | ||
| 74 | continue | ||
| 75 | if class_ not in CLASS_TO_ORGANIZER: | ||
| 76 | raise Exception(f"unknown class: {class_}") | ||
| 77 | if organizer is not None: | ||
| 78 | raise Exception(f"duplicate organizer") | ||
| 79 | organizer = CLASS_TO_ORGANIZER[class_] | ||
| 80 | if organizer is not None: | ||
| 81 | with open(organizer_path, "w") as f: | ||
| 82 | f.write(organizer) | ||
| 83 | |||
