diff options
author | rsiddharth <rsd@gnu.org> | 2018-03-22 04:19:04 +0000 |
---|---|---|
committer | rsiddharth <rsd@gnu.org> | 2018-03-22 04:34:33 +0000 |
commit | 9f2f570a45a4b01a14b5d03cb598ab73114d9eb7 (patch) | |
tree | 19c79a456a3ba0a4a3971871c0234f4725562699 /lps_gen.py | |
parent | 8f83f1b38c108615e39c697c08f2172b8cafd8f8 (diff) |
lps_gen.py: Update LPiCal timeslot regex slurping.
Now matches time slots of the form:
09:45 - 10:30: Lorem ipsum dolor sit.
or
09:45 - 10:30 - Lorem ipsum dolor sit.
or
09:45 - 10:30
* lps_gen.py (LPiCal.timeslot_r): Update variable.
(LPiCal.get_timeslot): Update method.
* tests/test_lps_gen.py (TestLPiCal.test_get_timeslot): Update test.
Diffstat (limited to 'lps_gen.py')
-rw-r--r-- | lps_gen.py | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2015-2017 lpschedule-generator contributors. See -# CONTRIBUTORS. +# Copyright (C) 2018 lpschedule-generator contributors. See CONTRIBUTORS. # # This file is part of lpschedule-generator. # @@ -120,7 +119,7 @@ class LPiCal(object): # Matches strings like '09:45 - 10:30: Lorem ipsum dolor sit.' self.timeslot_re = re.compile(r'(\d+:\d+).+?(\d+:\d+)' - + r':?\s*(.+\b)?') + r'\s*[:-]?\s*(.+\b)?') # Matches strings like 'Saturday, March 19' self.month_day_re = re.compile(r'\w+,\s*([a-zA-Z]+)\s*(\d+)') @@ -153,12 +152,12 @@ class LPiCal(object): timeslot = self.timeslot_re.search(s) - if (not timeslot) or (len(timeslot.groups()) < 3): + if not timeslot: return None, None, None t_start = timeslot.group(1) t_end = timeslot.group(2) - name = timeslot.group(3) + name = timeslot.group(3) or '' return t_start, t_end, name |