From d412e3cc2b80768a610984aa8c137083d623504e Mon Sep 17 00:00:00 2001 From: Tatham Oddie Date: Tue, 21 May 2024 00:36:24 +1000 Subject: [PATCH] Fix mansfield_vic_gov_au (#2096) * fix mansfield_vic_gov_au * reformatting --------- Co-authored-by: 5ila5 <5ila5@users.noreply.github.com> --- .../source/mansfield_vic_gov_au.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/mansfield_vic_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/mansfield_vic_gov_au.py index 1b2d9fba..30b35f80 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/mansfield_vic_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/mansfield_vic_gov_au.py @@ -69,10 +69,13 @@ class Source: for article in soup.find_all("article"): waste_type = article.h3.string icon = ICON_MAP.get(waste_type) - next_pickup = article.find(class_="next-service").string.strip() - if re.match(r"[^\s]* \d{1,2}\/\d{1,2}\/\d{4}", next_pickup): + next_pickup = article.find(class_="next-service").string + if next_pickup is None: + continue + date_match = re.search(r"\d{1,2}\/\d{1,2}\/\d{4}", next_pickup) + if date_match: next_pickup_date = datetime.strptime( - next_pickup.split(sep=" ")[1], "%d/%m/%Y" + date_match.group(0), "%d/%m/%Y" ).date() entries.append( Collection(date=next_pickup_date, t=waste_type, icon=icon)