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:
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user