templatetags: add 'r' prefix to regex strings (#48919)
This commit is contained in:
parent
1ece478eb9
commit
226207a916
|
@ -180,7 +180,7 @@ def get_slots_from_mdr_format(data, today):
|
||||||
if not hours:
|
if not hours:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
parts = re.match('(\d?\d)h(\d\d)-(\d?\d)h(\d\d)', hours).groups()
|
parts = re.match(r'(\d?\d)h(\d\d)-(\d?\d)h(\d\d)', hours).groups()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
# add to slots the opening hours in chronological order beginning from today
|
# add to slots the opening hours in chronological order beginning from today
|
||||||
|
@ -207,13 +207,13 @@ def parse_opening_hours_data(mairie_data):
|
||||||
for openinghours in mairie_data.get('openinghours', []):
|
for openinghours in mairie_data.get('openinghours', []):
|
||||||
# format is comma-separated days and/or intervals, or only one day
|
# format is comma-separated days and/or intervals, or only one day
|
||||||
try:
|
try:
|
||||||
groups = re.match('(\w\w(?:(?:,|\-)?\w\w)*) (\d\d?):(\d\d?)-(\d\d?):(\d\d?)', openinghours).groups()
|
groups = re.match(r'(\w\w(?:(?:,|\-)?\w\w)*) (\d\d?):(\d\d?)-(\d\d?):(\d\d?)', openinghours).groups()
|
||||||
except AttributeError: # invalid input data
|
except AttributeError: # invalid input data
|
||||||
continue
|
continue
|
||||||
for day in groups[0].split(','):
|
for day in groups[0].split(','):
|
||||||
if '-' in day:
|
if '-' in day:
|
||||||
# interval
|
# interval
|
||||||
parts = re.match('(\w\w)-(\w\w)', day).groups() + groups[1:]
|
parts = re.match(r'(\w\w)-(\w\w)', day).groups() + groups[1:]
|
||||||
time_table = dict(zip(('start_day', 'end_day', 'start_hour', 'start_minute', 'end_hour', 'end_minute'), parts))
|
time_table = dict(zip(('start_day', 'end_day', 'start_hour', 'start_minute', 'end_hour', 'end_minute'), parts))
|
||||||
days_list = EN_ABBREV_WEEKDAYS_LIST[
|
days_list = EN_ABBREV_WEEKDAYS_LIST[
|
||||||
EN_ABBREV_WEEKDAYS_LIST.index(time_table['start_day'].lower()):
|
EN_ABBREV_WEEKDAYS_LIST.index(time_table['start_day'].lower()):
|
||||||
|
|
Loading…
Reference in New Issue