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