Skip to content

Commit

Permalink
ellas: dont crash if name is not uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
trnila committed Nov 15, 2024
1 parent 69a54ae commit 53d27f6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lunches.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,14 @@ def ellas(dom):
for food in foods[1:]:
if food.text():
parsed = re.match(
r"\s*(?P<num>[0-9]+)\s*\.\s*(?P<name>[A-Z -]+)\s+(?P<ingredients>.*?)\s*(\([0-9 ,]+\))?\s*(?P<price>[0-9]+),-", # noqa: E501
r"\s*(?P<num>[0-9]+)\s*\.\s*(?P<name>.*?)\s*(\([0-9 ,]+\))?\s*(?P<price>[0-9]+),-", # noqa: E501
food.text(),
).groupdict()

m = re.match(r"^(?P<name>[A-Z -]+)\s+(?P<ingredients>.*?)$", parsed["name"])
if m:
parsed.update(m.groupdict())

yield Lunch(**parsed)


Expand Down

0 comments on commit 53d27f6

Please sign in to comment.