From 10422d049902b23c3b54753868e58d651f24e285 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 12 Oct 2024 21:26:18 +0200 Subject: [PATCH] WIP --- .../import_tasks/custom_extractors/acolab.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/agenda_culturel/import_tasks/custom_extractors/acolab.py b/src/agenda_culturel/import_tasks/custom_extractors/acolab.py index d9e76db..30051ea 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors/acolab.py +++ b/src/agenda_culturel/import_tasks/custom_extractors/acolab.py @@ -75,6 +75,9 @@ class CExtractor(Extractor): def find_timeslot(text): text = re.sub(' +', ' ', text).split(' ') + if len(text) < 3: + return None + day_name = text[0] day_num = text[1] hours = text[2] @@ -88,6 +91,7 @@ class CExtractor(Extractor): day_num = int(day_num[0]) hours = CExtractor.find_hours(hours) + if hours is None: return None @@ -109,6 +113,7 @@ class CExtractor(Extractor): for e in p.stripped_strings: day = CExtractor.find_timeslot(e) if not day is None: + print('on a une date', day) if not date is None and is_open: # we reach a new day result.append((date, slot)) @@ -124,12 +129,14 @@ class CExtractor(Extractor): continue if CExtractor.is_nickname(e): + print('on a un nickname', e) # we found a nickname is_open = True continue hours = CExtractor.find_hours(e) if not hours is None: + print('on a une heure', hours) if slot is None: slot = hours else: @@ -137,6 +144,7 @@ class CExtractor(Extractor): continue if CExtractor.is_canceled(e): + print('on a un cancel') is_open = False continue @@ -166,10 +174,8 @@ class CExtractor(Extractor): # annule # menage for p in description.select('p'): - CExtractor.find_timeslots(p) - - if not '@' in p.text: - continue + ts = CExtractor.find_timeslots(p) + print(ts, when, title)