Show More
@@ -195,12 +195,12 b' class HistoryManager(Configurable):' | |||
|
195 | 195 | |
|
196 | 196 | # Assemble the SQL query: |
|
197 | 197 | sqlfrom = "history" |
|
198 | toget = 'source_raw' if raw else 'source' | |
|
198 | toget = "session, line, " +('source_raw' if raw else 'source') | |
|
199 | 199 | if output: |
|
200 | 200 | sqlfrom = "history LEFT JOIN output_history USING (session, line)" |
|
201 | 201 | toget = "history.%s, output_history.output" % toget |
|
202 | 202 | if stop: |
|
203 |
lineclause = "line |
|
|
203 | lineclause = "line >= ? AND line < ?" | |
|
204 | 204 | params = (session, start, stop) |
|
205 | 205 | else: |
|
206 | 206 | lineclause = "line>=?" |
@@ -215,8 +215,8 b' class HistoryManager(Configurable):' | |||
|
215 | 215 | def get_hist_from_rangestr(self, rangestr, raw=True, output=False): |
|
216 | 216 | """Get lines of history from a string of ranges, as used by magic |
|
217 | 217 | commands %hist, %save, %macro, etc.""" |
|
218 |
for |
|
|
219 |
for line in self.get_history( |
|
|
218 | for sess, s, e in extract_hist_ranges(rangestr): | |
|
219 | for line in self.get_history(sess, s, e, raw=raw, output=output): | |
|
220 | 220 | yield line |
|
221 | 221 | |
|
222 | 222 | def store_inputs(self, line_num, source, source_raw=None): |
@@ -301,12 +301,12 b' class HistoryManager(Configurable):' | |||
|
301 | 301 | # The directory history can't be completely empty |
|
302 | 302 | self.dir_hist[:] = [os.getcwd()] |
|
303 | 303 | |
|
304 |
# To match, e.g. ~5 |
|
|
304 | # To match, e.g. ~5/8-~2/3 | |
|
305 | 305 | range_re = re.compile(r""" |
|
306 |
((?P<startsess>~?\d+) |
|
|
306 | ((?P<startsess>~?\d+)/)? | |
|
307 | 307 | (?P<start>\d+) # Only the start line num is compulsory |
|
308 | 308 | ((?P<sep>[\-:]) |
|
309 |
((?P<endsess>~?\d+) |
|
|
309 | ((?P<endsess>~?\d+)/)? | |
|
310 | 310 | (?P<end>\d+))? |
|
311 | 311 | """, re.VERBOSE) |
|
312 | 312 | |
@@ -315,10 +315,9 b' def extract_hist_ranges(ranges_str):' | |||
|
315 | 315 | |
|
316 | 316 | Examples |
|
317 | 317 | -------- |
|
318 |
list(extract_input_ranges("~8 |
|
|
318 | list(extract_input_ranges("~8/5-~7/4 2")) | |
|
319 | 319 | [(-8, 5, None), (-7, 1, 4), (0, 2, 3)] |
|
320 | 320 | """ |
|
321 | print(ranges_str) | |
|
322 | 321 | for range_str in ranges_str.split(): |
|
323 | 322 | rmatch = range_re.match(range_str) |
|
324 | 323 | start = int(rmatch.group("start")) |
General Comments 0
You need to be logged in to leave comments.
Login now