Show More
@@ -630,18 +630,20 b" def magic_rerun(self, parameter_s=''):" | |||||
630 | opts, args = self.parse_options(parameter_s, 'l:g:', mode='string') |
|
630 | opts, args = self.parse_options(parameter_s, 'l:g:', mode='string') | |
631 | if "l" in opts: # Last n lines |
|
631 | if "l" in opts: # Last n lines | |
632 | n = int(opts['l']) |
|
632 | n = int(opts['l']) | |
633 |
hist = self.history_manager.get_hist_tail(n |
|
633 | hist = self.history_manager.get_hist_tail(n) | |
634 | elif "g" in opts: # Search |
|
634 | elif "g" in opts: # Search | |
635 | p = "*"+opts['g']+"*" |
|
635 | p = "*"+opts['g']+"*" | |
636 |
hist = self.history_manager.get_hist_search(p |
|
636 | hist = list(self.history_manager.get_hist_search(p)) | |
637 |
|
|
637 | for l in reversed(hist): | |
638 |
if |
|
638 | if "rerun" not in l[2]: | |
639 | hist = hist[:-1] # We can ignore the current line |
|
639 | hist = [l] # The last match which isn't a %rerun | |
640 | hist = hist[-1:] # Just get the last match |
|
640 | break | |
|
641 | else: | |||
|
642 | hist = [] # No matches except %rerun | |||
641 | elif args: # Specify history ranges |
|
643 | elif args: # Specify history ranges | |
642 | hist = self.history_manager.get_hist_from_rangestr(args) |
|
644 | hist = self.history_manager.get_hist_from_rangestr(args) | |
643 | else: # Last line |
|
645 | else: # Last line | |
644 |
hist = self.history_manager.get_hist_tail(1 |
|
646 | hist = self.history_manager.get_hist_tail(1) | |
645 | hist = [x[2] for x in hist] |
|
647 | hist = [x[2] for x in hist] | |
646 | if not hist: |
|
648 | if not hist: | |
647 | print("No lines in history match specification") |
|
649 | print("No lines in history match specification") | |
@@ -650,7 +652,7 b" def magic_rerun(self, parameter_s=''):" | |||||
650 | print("=== Executing: ===") |
|
652 | print("=== Executing: ===") | |
651 | print(histlines) |
|
653 | print(histlines) | |
652 | print("=== Output: ===") |
|
654 | print("=== Output: ===") | |
653 |
self.run_ |
|
655 | self.run_cell("\n".join(hist), store_history=False) | |
654 |
|
656 | |||
655 |
|
657 | |||
656 | def init_ipython(ip): |
|
658 | def init_ipython(ip): |
@@ -2060,7 +2060,7 b' class InteractiveShell(Configurable, Magic):' | |||||
2060 | self.showtraceback() |
|
2060 | self.showtraceback() | |
2061 | warn('Unknown failure executing file: <%s>' % fname) |
|
2061 | warn('Unknown failure executing file: <%s>' % fname) | |
2062 |
|
2062 | |||
2063 | def run_cell(self, cell): |
|
2063 | def run_cell(self, cell, store_history=True): | |
2064 | """Run the contents of an entire multiline 'cell' of code, and store it |
|
2064 | """Run the contents of an entire multiline 'cell' of code, and store it | |
2065 | in the history. |
|
2065 | in the history. | |
2066 |
|
2066 | |||
@@ -2111,7 +2111,9 b' class InteractiveShell(Configurable, Magic):' | |||||
2111 | cell = ''.join(blocks) |
|
2111 | cell = ''.join(blocks) | |
2112 |
|
2112 | |||
2113 | # Store raw and processed history |
|
2113 | # Store raw and processed history | |
2114 | self.history_manager.store_inputs(self.execution_count, cell, raw_cell) |
|
2114 | if store_history: | |
|
2115 | self.history_manager.store_inputs(self.execution_count, | |||
|
2116 | cell, raw_cell) | |||
2115 |
|
2117 | |||
2116 | self.logger.log(cell, raw_cell) |
|
2118 | self.logger.log(cell, raw_cell) | |
2117 |
|
2119 | |||
@@ -2123,6 +2125,7 b' class InteractiveShell(Configurable, Magic):' | |||||
2123 | out = self.run_source(blocks[0]) |
|
2125 | out = self.run_source(blocks[0]) | |
2124 | # Write output to the database. Does nothing unless |
|
2126 | # Write output to the database. Does nothing unless | |
2125 | # history output logging is enabled. |
|
2127 | # history output logging is enabled. | |
|
2128 | if store_history: | |||
2126 | self.history_manager.store_output(self.execution_count) |
|
2129 | self.history_manager.store_output(self.execution_count) | |
2127 | # since we return here, we need to update the execution count |
|
2130 | # since we return here, we need to update the execution count | |
2128 | self.execution_count += 1 |
|
2131 | self.execution_count += 1 | |
@@ -2154,6 +2157,7 b' class InteractiveShell(Configurable, Magic):' | |||||
2154 |
|
2157 | |||
2155 | # Write output to the database. Does nothing unless |
|
2158 | # Write output to the database. Does nothing unless | |
2156 | # history output logging is enabled. |
|
2159 | # history output logging is enabled. | |
|
2160 | if store_history: | |||
2157 | self.history_manager.store_output(self.execution_count) |
|
2161 | self.history_manager.store_output(self.execution_count) | |
2158 | # Each cell is a *single* input, regardless of how many lines it has |
|
2162 | # Each cell is a *single* input, regardless of how many lines it has | |
2159 | self.execution_count += 1 |
|
2163 | self.execution_count += 1 |
@@ -2369,7 +2369,8 b' Currently the magic system has the following functions:\\n"""' | |||||
2369 | else: |
|
2369 | else: | |
2370 | print 'done. Executing edited code...' |
|
2370 | print 'done. Executing edited code...' | |
2371 | if opts_raw: |
|
2371 | if opts_raw: | |
2372 |
self.shell.run_cell(file_read(filename) |
|
2372 | self.shell.run_cell(file_read(filename), | |
|
2373 | store_history=False) | |||
2373 | else: |
|
2374 | else: | |
2374 | self.shell.safe_execfile(filename,self.shell.user_ns, |
|
2375 | self.shell.safe_execfile(filename,self.shell.user_ns, | |
2375 | self.shell.user_ns) |
|
2376 | self.shell.user_ns) |
General Comments 0
You need to be logged in to leave comments.
Login now