From 5f1f5fd0031914ea394b52c8098bb100318ad6f1 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 12 Oct 2024 18:19:59 +0200 Subject: [PATCH] Les fonctions sont des fonctions de classe --- src/agenda_culturel/import_tasks/custom_extractors/c3c.py | 6 +++--- .../import_tasks/custom_extractors/lapucealoreille.py | 8 ++++---- .../import_tasks/custom_extractors/wordpress_mec.py | 6 +++--- src/agenda_culturel/import_tasks/extractor.py | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/agenda_culturel/import_tasks/custom_extractors/c3c.py b/src/agenda_culturel/import_tasks/custom_extractors/c3c.py index 08c5048..b335576 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors/c3c.py +++ b/src/agenda_culturel/import_tasks/custom_extractors/c3c.py @@ -50,7 +50,7 @@ class CExtractor(TwoStepsExtractor): description = soup.select_one(".presentation").get_text() duration = soup.select_one("#criteres .DUREE-V .valeur-critere li") if duration is not None: - duration = self.parse_french_time(duration.text) + duration = Extractor.parse_french_time(duration.text) location = self.nom_lieu categories = [] @@ -94,8 +94,8 @@ class CExtractor(TwoStepsExtractor): soup2 = BeautifulSoup(page2, "html.parser") times = [o.text for o in soup2.select("#quart_en_cours_spec option")] for t in times: - startdate = self.parse_french_date(date) - starttime = self.parse_french_time(t) + startdate = Extractor.parse_french_date(date) + starttime = Extractor.parse_french_time(t) start = datetime.datetime.combine(startdate, starttime) enddate = None endtime = None diff --git a/src/agenda_culturel/import_tasks/custom_extractors/lapucealoreille.py b/src/agenda_culturel/import_tasks/custom_extractors/lapucealoreille.py index e87395f..24df3f3 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors/lapucealoreille.py +++ b/src/agenda_culturel/import_tasks/custom_extractors/lapucealoreille.py @@ -41,13 +41,13 @@ class CExtractor(TwoStepsExtractor): for span in spans: txt = span.get_text() if txt.lstrip().startswith("DÉBUT"): - start_time = self.parse_french_time(txt.split(":")[-1]) + start_time = Extractor.parse_french_time(txt.split(":")[-1]) end_time = None elif txt.lstrip().startswith("HORAIRES :"): hs = txt.split(":")[-1].split("-") - start_time = self.parse_french_time(hs[0]) + start_time = Extractor.parse_french_time(hs[0]) if len(hs) > 1: - end_time = self.parse_french_time(hs[1]) + end_time = Extractor.parse_french_time(hs[1]) else: end_time = None elif txt.lstrip().startswith("LIEU :") and not location: @@ -55,7 +55,7 @@ class CExtractor(TwoStepsExtractor): if not location: location = self.nom_lieu - end_day = self.guess_end_day(start_day, start_time, end_time) + end_day = Extractor.guess_end_day(start_day, start_time, end_time) url_human = event_url tags = [] diff --git a/src/agenda_culturel/import_tasks/custom_extractors/wordpress_mec.py b/src/agenda_culturel/import_tasks/custom_extractors/wordpress_mec.py index cf0f2db..f44fcc5 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors/wordpress_mec.py +++ b/src/agenda_culturel/import_tasks/custom_extractors/wordpress_mec.py @@ -56,15 +56,15 @@ class CExtractor(TwoStepsExtractor): start_day = soup.select(".mec-start-date-label") if start_day and len(start_day) > 0: - start_day = self.parse_french_date(start_day[0].get_text()) + start_day = Extractor.parse_french_date(start_day[0].get_text()) else: start_day = None t = soup.select(".mec-single-event-time .mec-events-abbr") if t: t = t[0].get_text().split("-") - start_time = self.parse_french_time(t[0]) + start_time = Extractor.parse_french_time(t[0]) if len(t) > 1: - end_time = self.parse_french_time(t[1]) + end_time = Extractor.parse_french_time(t[1]) else: end_time = None else: diff --git a/src/agenda_culturel/import_tasks/extractor.py b/src/agenda_culturel/import_tasks/extractor.py index 7befc54..76135d9 100644 --- a/src/agenda_culturel/import_tasks/extractor.py +++ b/src/agenda_culturel/import_tasks/extractor.py @@ -18,7 +18,7 @@ class Extractor(ABC): self.downloader = None self.referer = "" - def guess_end_day(self, start_day, start_time, end_time): + def guess_end_day(start_day, start_time, end_time): if end_time: if end_time > start_time: return start_day @@ -48,7 +48,7 @@ class Extractor(ABC): return i + 1 return None - def parse_french_date(self, text): + def parse_french_date(text): # format NomJour Numero Mois Année m = re.search( "[a-zA-ZéÉûÛ:.]+[ ]*([0-9]+)[er]*[ ]*([a-zA-ZéÉûÛ:.]+)[ ]*([0-9]+)", text @@ -88,7 +88,7 @@ class Extractor(ABC): return None return date(year, month, day) - def parse_french_time(self, text): + def parse_french_time(text): # format heures minutes secondes m = re.search("([0-9]+)[ a-zA-Z:.]+([0-9]+)[ a-zA-Z:.]+([0-9]+)", text) if m: