Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thueringen: added Abend prefix in category for dinners #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions parsers/thueringen.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ def parse_meals(document):
misc = []
for misc_category in meal.find_all(class_='splIconMeal'):
misc.append(misc_category['title'])

# look whether meal is in a container which also contains Abendessen class
meal_container = meal.find_parent(class_='splGroupWrapper')
meal_time = None
if meal_container:
meal_time = meal_container.find(class_='splGroupAbendmensa')

info = {
'additives': additives_regex.findall(additives_element.string) if additives_element and additives_element.string else [],
'allergens': allergens_regex.findall(allergens_element.string) if allergens_element and allergens_element.string else [],
'misc': misc
'misc': misc,
'is_dinner': meal_time != None and meal_time.string == 'Abendessen'
}
prices_element = meal.find_next(class_='mealPreise')
prices = price_regex.findall(prices_element.string) if prices_element else None
Expand Down Expand Up @@ -81,6 +88,9 @@ def parse_single_date(self, date):
elif 'Fisch' in info['misc']:
category = 'Fisch'

if info['is_dinner']:
category = 'Abend: {}'.format(category)

additives = 'Zusatzstoffe: ' + ', '.join((legend[item] for item in info['additives'])) if info['additives'] else 'ohne deklarationspflichtige Zusatzstoffe'
allergens = 'Allergene: ' + ', '.join((legend[item] for item in info['allergens'])) if info['allergens'] else ''
# remove information which is already present in the category
Expand Down Expand Up @@ -126,7 +136,7 @@ def full(self, request):
self.parse_data(day, False)
return self.feed.toXMLFeed()

parser = Parser('thueringen', version='2.0')
parser = Parser('thueringen', version='2.1')
Canteen('ei-wartenberg', parser, canteen_id=69)
Canteen('ef-nordhaeuser', parser, canteen_id=44)
Canteen('ef-altonaer', parser, canteen_id=47)
Expand Down