silently skip invalid schedule data (#26912)

This commit is contained in:
Frédéric Péters 2018-10-02 14:04:32 +02:00
parent 42cf0c7303
commit e83aba4a50
1 changed files with 4 additions and 1 deletions

View File

@ -160,7 +160,10 @@ def parse_opening_hours_data(mairie_data):
"""
for openinghours in mairie_data.get('openinghours', []):
# format is comma-separated days and/or intervals, or only one day
groups = re.match('(\w\w(?:(?:,|\-)?\w\w)*) (\d\d?):(\d\d?)-(\d\d?):(\d\d?)', openinghours).groups()
try:
groups = re.match('(\w\w(?:(?:,|\-)?\w\w)*) (\d\d?):(\d\d?)-(\d\d?):(\d\d?)', openinghours).groups()
except AttributeError: # invalid input data
continue
for day in groups[0].split(','):
if '-' in day:
# interval