From 295e8336214993c3126127cea420e847f714dc8b Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 25 Sep 2023 18:02:14 +0100 Subject: [PATCH] Scripts live in their own dir --- scripts/add_conference_urls.py | 55 ++++++++++++++++++++++++++++ add_place.py => scripts/add_place.py | 3 +- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100755 scripts/add_conference_urls.py rename add_place.py => scripts/add_place.py (99%) diff --git a/scripts/add_conference_urls.py b/scripts/add_conference_urls.py new file mode 100755 index 0000000..49b7feb --- /dev/null +++ b/scripts/add_conference_urls.py @@ -0,0 +1,55 @@ +#!/usr/bin/python3 + +import os +import json +from confarchive import database, model +from confarchive.view import app + +app.config.from_object("config.default") +database.init_app(app) + + +def url_from_giggty_menu() -> None: + for conf in model.Conference.query.order_by(model.Conference.short_name): + if conf.url: + continue + + giggity_menu = "giggity/menu/" + + menu_filename = os.path.join(giggity_menu, conf.short_name + ".json") + + if not os.path.exists(menu_filename): + continue + + menu = json.load(open(menu_filename)) + links = {link["title"]: link["url"] for link in menu["metadata"]["links"]} + + if "Website" not in links: + continue + print(json.dumps(links, indent=2)) + + url = links["Website"] + + print(conf.short_name, menu_filename, url) + + conf.url = url + + database.session.commit() + + +def add_more_urls() -> None: + for conf in model.Conference.query.order_by(model.Conference.short_name): + if conf.url: + continue + if conf.short_name.startswith("debconf"): + conf.url = f"https://{conf.short_name}.debconf.org/" + print(conf.short_name, conf.url) + if conf.short_name.startswith("fosdem"): + year = conf.short_name[-4:] + conf.url = f"https://fosdem.org/{year}/" + print(conf.short_name, conf.url) + + database.session.commit() + + +add_more_urls() diff --git a/add_place.py b/scripts/add_place.py similarity index 99% rename from add_place.py rename to scripts/add_place.py index 61d0b92..8bce27a 100755 --- a/add_place.py +++ b/scripts/add_place.py @@ -1,9 +1,8 @@ #!/usr/bin/python3 -from main import app import sys from confarchive import database, model, wikidata - +from confarchive.view import app app.config.from_object("config.default") database.init_app(app)