From 44b6458d7328df261f5537300a7f7e116e01aa03 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 20 Apr 2024 13:54:28 +0200 Subject: [PATCH] Photomat -> Fotomat --- experimentations/.gitignore | 1 + .../{get_lephotomat.py => get_lefotomat.py} | 6 +++--- src/agenda_culturel/celery.py | 4 ++-- .../import_tasks/custom_extractors.py | 10 +++++----- .../migrations/0052_auto_20240420_1353.py | 13 +++++++++++++ .../0053_alter_recurrentimport_processor.py | 18 ++++++++++++++++++ src/agenda_culturel/models.py | 2 +- 7 files changed, 43 insertions(+), 11 deletions(-) rename experimentations/{get_lephotomat.py => get_lefotomat.py} (79%) create mode 100644 src/agenda_culturel/migrations/0052_auto_20240420_1353.py create mode 100644 src/agenda_culturel/migrations/0053_alter_recurrentimport_processor.py diff --git a/experimentations/.gitignore b/experimentations/.gitignore index 0c94727..a81ec95 100644 --- a/experimentations/.gitignore +++ b/experimentations/.gitignore @@ -1,3 +1,4 @@ *.json *.html *.ical +*.xml diff --git a/experimentations/get_lephotomat.py b/experimentations/get_lefotomat.py similarity index 79% rename from experimentations/get_lephotomat.py rename to experimentations/get_lefotomat.py index 7a9c641..18d8cc8 100755 --- a/experimentations/get_lephotomat.py +++ b/experimentations/get_lefotomat.py @@ -28,14 +28,14 @@ from src.agenda_culturel.import_tasks.custom_extractors import * if __name__ == "__main__": - u2e = URL2Events(SimpleDownloader(), LePhotomatExtractor()) + u2e = URL2Events(SimpleDownloader(), LeFotomatExtractor()) url = "https://www.lefotomat.com/feed" url_human = "https://www.lefotomat.com/" try: - events = u2e.process(url, url_human, cache = "cache-lephotomat.xml", default_values = {"location": "Le Photomat'"}, published = True) + events = u2e.process(url, url_human, cache = "cache-lefotomat.xml", default_values = {"location": "Le Fotomat'"}, published = True) - exportfile = "events-lephotomat.json" + exportfile = "events-lefotomat.json" print("Saving events to file {}".format(exportfile)) with open(exportfile, "w") as f: json.dump(events, f, indent=4, default=str) diff --git a/src/agenda_culturel/celery.py b/src/agenda_culturel/celery.py index 3e8986f..38b5ad6 100644 --- a/src/agenda_culturel/celery.py +++ b/src/agenda_culturel/celery.py @@ -105,8 +105,8 @@ def run_recurrent_import(self, pk): extractor = LaCoopeExtractor() elif rimport.processor == RecurrentImport.PROCESSOR.LACOMEDIE: extractor = LaComedieExtractor() - elif rimport.processor == RecurrentImport.PROCESSOR.LEPHOTOMAT: - extractor = LePhotomatExtractor() + elif rimport.processor == RecurrentImport.PROCESSOR.LEFOTOMAT: + extractor = LeFotomatExtractor() else: extractor = None diff --git a/src/agenda_culturel/import_tasks/custom_extractors.py b/src/agenda_culturel/import_tasks/custom_extractors.py index 95e01dc..95dc26c 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors.py +++ b/src/agenda_culturel/import_tasks/custom_extractors.py @@ -130,13 +130,13 @@ class LaComedieExtractor(TwoStepsExtractor): -# A class dedicated to get events from Le Photomat' +# A class dedicated to get events from Le Fotomat' # URL: https://www.lefotomat.com/ -class LePhotomatExtractor(TwoStepsExtractor): +class LeFotomatExtractor(TwoStepsExtractor): - nom_lieu = "Le Photomat'" + nom_lieu = "Le Fotomat'" - def category_photomat2agenda(self, category): + def category_fotomat2agenda(self, category): if not category: return None mapping = { "Concerts": "Concert"} @@ -157,7 +157,7 @@ class LePhotomatExtractor(TwoStepsExtractor): title = e.find("title").contents[0] self.add_event_title(e_url, title) - category = self.category_photomat2agenda(e.find("category").contents[0]) + category = self.category_fotomat2agenda(e.find("category").contents[0]) if category: self.add_event_category(e_url, category) diff --git a/src/agenda_culturel/migrations/0052_auto_20240420_1353.py b/src/agenda_culturel/migrations/0052_auto_20240420_1353.py new file mode 100644 index 0000000..6d62805 --- /dev/null +++ b/src/agenda_culturel/migrations/0052_auto_20240420_1353.py @@ -0,0 +1,13 @@ +# Generated by Django 4.2.7 on 2024-04-20 11:53 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0051_alter_recurrentimport_processor'), + ] + + operations = [ + ] diff --git a/src/agenda_culturel/migrations/0053_alter_recurrentimport_processor.py b/src/agenda_culturel/migrations/0053_alter_recurrentimport_processor.py new file mode 100644 index 0000000..ef431c7 --- /dev/null +++ b/src/agenda_culturel/migrations/0053_alter_recurrentimport_processor.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-04-20 11:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0052_auto_20240420_1353'), + ] + + operations = [ + migrations.AlterField( + model_name='recurrentimport', + name='processor', + field=models.CharField(choices=[('ical', 'ical'), ('icalnobusy', 'ical no busy'), ('icalnovc', 'ical no VC'), ('lacoope', 'lacoope.org'), ('lacomedie', 'la comédie'), ('lefotomat', 'le fotomat')], default='ical', max_length=20, verbose_name='Processor'), + ), + ] diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 19b2ec2..0b04bcf 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -759,7 +759,7 @@ class RecurrentImport(models.Model): ICALNOVC = "icalnovc", _("ical no VC") LACOOPE = "lacoope", _('lacoope.org') LACOMEDIE = "lacomedie", _('la comédie') - LEPHOTOMAT = "lephotomat", _('le photomat') + LEFOTOMAT = "lefotomat", _('le fotomat') class DOWNLOADER(models.TextChoices): SIMPLE = "simple", _("simple")