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