summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lps_gen.py9
-rw-r--r--tests/test_lps_gen.py10
2 files changed, 13 insertions, 6 deletions
diff --git a/lps_gen.py b/lps_gen.py
index acaabf2..23fbede 100644
--- a/lps_gen.py
+++ b/lps_gen.py
@@ -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
diff --git a/tests/test_lps_gen.py b/tests/test_lps_gen.py
index 4ac2730..e32b52e 100644
--- a/tests/test_lps_gen.py
+++ b/tests/test_lps_gen.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2015-2016 lpschedule-generator contributors. See CONTRIBUTORS.
+# Copyright (C) 2018 lpschedule-generator contributors. See CONTRIBUTORS.
#
# This file is part of lpschedule-generator.
#
@@ -188,6 +188,14 @@ class TestLPiCal(object):
[None, None, None],
' ':
[None, None, None],
+ '10:00 - 10:45 - Keynote':
+ ['10:00', '10:45', 'Keynote'],
+ '16:20 - 17:05':
+ ['16:20', '17:05', ''],
+ '16:25-17:25':
+ ['16:25', '17:25', ''],
+ '17:05-17:15 - Break':
+ ['17:05', '17:15', 'Break']
}
for string, timeslot in timeslots.iteritems():