From 6a03aba4e99e824925fbc48785083b50b7d20ff2 Mon Sep 17 00:00:00 2001 From: Adrian Rumpold Date: Thu, 1 Jul 2021 13:11:04 +0200 Subject: [PATCH] fix: Deal with new date format, better error handling --- .../home_assistant_covid19_augsburg/crawler.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/custom_components/home_assistant_covid19_augsburg/crawler.py b/custom_components/home_assistant_covid19_augsburg/crawler.py index a9a6748..92dcd1d 100644 --- a/custom_components/home_assistant_covid19_augsburg/crawler.py +++ b/custom_components/home_assistant_covid19_augsburg/crawler.py @@ -67,15 +67,17 @@ class CovidCrawler(CovidCrawlerBase): matches = re.search(r"(\d+,\d+)\sNeuinfektion", text) if not matches: - raise ValueError("Could not extract incidence from scraped web page") + raise ValueError( + f"Could not extract incidence from scraped web page, {text=}" + ) incidence = parse_num(matches.group(1), t=float) _log.debug(f"Parsed incidence: {incidence}") text = match.h2.text - matches = re.search(r"\((\d+)\. (\w+)\)", text) + matches = re.search(r"\((\d+)\. (\w+).*\)", text) if not matches: - raise ValueError("Could not extract date from scraped web page") + raise ValueError(f"Could not extract date from scraped web page, {text=}") months = [ "Januar",