Fix Breaking Changes Due to Changes in the Mensa Website (#27)

* Fix opening time parsing, add fallback for incorrectly parsed price

* Reset formatting

* Linting

* Replace too broad catch with more specific None check
This commit is contained in:
Tobias
2024-10-18 17:14:48 +02:00
committed by GitHub
parent 6e9e0732e9
commit afb6ad2593
2 changed files with 5 additions and 2 deletions
+2
View File
@@ -40,6 +40,8 @@ class MealXML:
continue
price = doc.createElement("price")
price.setAttribute("role", key)
if val is None:
val = 0.0
txt_node = doc.createTextNode(f"{val:.2f}")
price.appendChild(txt_node)
meal.appendChild(price)
+3 -2
View File
@@ -15,8 +15,9 @@ class CanteenOpenTimespec(str):
"",
}
PATTERN = (r'.*(?P<hour1>\d{1,2}):(?P<min1>\d{1,2})\s*'
r'-\s*(?P<hour2>\d{1,2}):(?P<min2>\d{1,2}).*')
PATTERN = (r'.*(?P<hour1>\d{1,2}):(?P<min1>\d{1,2})'
r'\D*(?P<hour2>\d{1,2}):(?P<min2>\d{1,2}).*')
MATCHER = re.compile(PATTERN)
def __new__(cls, spec):