Show More
@@ -748,7 +748,7 b' class HistorySavingThread(threading.Thread):' | |||||
748 | # To match, e.g. ~5/8-~2/3 |
|
748 | # To match, e.g. ~5/8-~2/3 | |
749 | range_re = re.compile(r""" |
|
749 | range_re = re.compile(r""" | |
750 | ((?P<startsess>~?\d+)/)? |
|
750 | ((?P<startsess>~?\d+)/)? | |
751 | (?P<start>\d+) # Only the start line num is compulsory |
|
751 | (?P<start>\d+)? | |
752 | ((?P<sep>[\-:]) |
|
752 | ((?P<sep>[\-:]) | |
753 | ((?P<endsess>~?\d+)/)? |
|
753 | ((?P<endsess>~?\d+)/)? | |
754 | (?P<end>\d+))? |
|
754 | (?P<end>\d+))? | |
@@ -767,9 +767,18 b' def extract_hist_ranges(ranges_str):' | |||||
767 | rmatch = range_re.match(range_str) |
|
767 | rmatch = range_re.match(range_str) | |
768 | if not rmatch: |
|
768 | if not rmatch: | |
769 | continue |
|
769 | continue | |
770 |
start = |
|
770 | start = rmatch.group("start") | |
771 | end = rmatch.group("end") |
|
771 | if start: | |
772 | end = int(end) if end else start+1 # If no end specified, get (a, a+1) |
|
772 | start = int(start) | |
|
773 | end = rmatch.group("end") | |||
|
774 | # If no end specified, get (a, a + 1) | |||
|
775 | end = int(end) if end else start + 1 | |||
|
776 | else: # start not specified | |||
|
777 | if not rmatch.group('startsess'): # no startsess | |||
|
778 | continue | |||
|
779 | start = 1 | |||
|
780 | end = None # provide the entire session hist | |||
|
781 | ||||
773 | if rmatch.group("sep") == "-": # 1-3 == 1:4 --> [1, 2, 3] |
|
782 | if rmatch.group("sep") == "-": # 1-3 == 1:4 --> [1, 2, 3] | |
774 | end += 1 |
|
783 | end += 1 | |
775 | startsess = rmatch.group("startsess") or "0" |
|
784 | startsess = rmatch.group("startsess") or "0" |
@@ -141,14 +141,15 b' def test_history():' | |||||
141 |
|
141 | |||
142 |
|
142 | |||
143 | def test_extract_hist_ranges(): |
|
143 | def test_extract_hist_ranges(): | |
144 | instr = "1 2/3 ~4/5-6 ~4/7-~4/9 ~9/2-~7/5" |
|
144 | instr = "1 2/3 ~4/5-6 ~4/7-~4/9 ~9/2-~7/5 ~10/" | |
145 | expected = [(0, 1, 2), # 0 == current session |
|
145 | expected = [(0, 1, 2), # 0 == current session | |
146 | (2, 3, 4), |
|
146 | (2, 3, 4), | |
147 | (-4, 5, 7), |
|
147 | (-4, 5, 7), | |
148 | (-4, 7, 10), |
|
148 | (-4, 7, 10), | |
149 | (-9, 2, None), # None == to end |
|
149 | (-9, 2, None), # None == to end | |
150 | (-8, 1, None), |
|
150 | (-8, 1, None), | |
151 |
(-7, 1, 6) |
|
151 | (-7, 1, 6), | |
|
152 | (-10, 1, None)] | |||
152 | actual = list(extract_hist_ranges(instr)) |
|
153 | actual = list(extract_hist_ranges(instr)) | |
153 | nt.assert_equal(actual, expected) |
|
154 | nt.assert_equal(actual, expected) | |
154 |
|
155 |
General Comments 0
You need to be logged in to leave comments.
Login now