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