Show More
@@ -2754,6 +2754,29 b' class InteractiveShell(SingletonConfigurable):' | |||||
2754 | """Show a usage message""" |
|
2754 | """Show a usage message""" | |
2755 | page.page(IPython.core.usage.interactive_usage) |
|
2755 | page.page(IPython.core.usage.interactive_usage) | |
2756 |
|
2756 | |||
|
2757 | def extract_input_lines(self, range_str, raw=False): | |||
|
2758 | """Return as a string a set of input history slices. | |||
|
2759 | ||||
|
2760 | Parameters | |||
|
2761 | ---------- | |||
|
2762 | range_str : string | |||
|
2763 | The set of slices is given as a string, like "~5/6-~4/2 4:8 9", | |||
|
2764 | since this function is for use by magic functions which get their | |||
|
2765 | arguments as strings. The number before the / is the session | |||
|
2766 | number: ~n goes n back from the current session. | |||
|
2767 | ||||
|
2768 | Optional Parameters: | |||
|
2769 | - raw(False): by default, the processed input is used. If this is | |||
|
2770 | true, the raw input history is used instead. | |||
|
2771 | ||||
|
2772 | Note that slices can be called with two notations: | |||
|
2773 | ||||
|
2774 | N:M -> standard python form, means including items N...(M-1). | |||
|
2775 | ||||
|
2776 | N-M -> include items N..M (closed endpoint).""" | |||
|
2777 | lines = self.history_manager.get_range_by_str(range_str, raw=raw) | |||
|
2778 | return "\n".join(x for _, _, x in lines) | |||
|
2779 | ||||
2757 | def find_user_code(self, target, raw=True, py_only=False): |
|
2780 | def find_user_code(self, target, raw=True, py_only=False): | |
2758 | """Get a code string from history, file, url, or a string or macro. |
|
2781 | """Get a code string from history, file, url, or a string or macro. | |
2759 |
|
2782 |
@@ -179,30 +179,6 b' python-profiler package from non-free.""")' | |||||
179 | out.sort() |
|
179 | out.sort() | |
180 | return out |
|
180 | return out | |
181 |
|
181 | |||
182 | def extract_input_lines(self, range_str, raw=False): |
|
|||
183 | """Return as a string a set of input history slices. |
|
|||
184 |
|
||||
185 | Parameters |
|
|||
186 | ---------- |
|
|||
187 | range_str : string |
|
|||
188 | The set of slices is given as a string, like "~5/6-~4/2 4:8 9", |
|
|||
189 | since this function is for use by magic functions which get their |
|
|||
190 | arguments as strings. The number before the / is the session |
|
|||
191 | number: ~n goes n back from the current session. |
|
|||
192 |
|
||||
193 | Optional Parameters: |
|
|||
194 | - raw(False): by default, the processed input is used. If this is |
|
|||
195 | true, the raw input history is used instead. |
|
|||
196 |
|
||||
197 | Note that slices can be called with two notations: |
|
|||
198 |
|
||||
199 | N:M -> standard python form, means including items N...(M-1). |
|
|||
200 |
|
||||
201 | N-M -> include items N..M (closed endpoint).""" |
|
|||
202 | lines = self.shell.history_manager.\ |
|
|||
203 | get_range_by_str(range_str, raw=raw) |
|
|||
204 | return "\n".join(x for _, _, x in lines) |
|
|||
205 |
|
||||
206 | def arg_err(self,func): |
|
182 | def arg_err(self,func): | |
207 | """Print docstring if incorrect arguments were passed""" |
|
183 | """Print docstring if incorrect arguments were passed""" | |
208 | print 'Error in arguments:' |
|
184 | print 'Error in arguments:' | |
@@ -2370,7 +2346,7 b' Currently the magic system has the following functions:\\n"""' | |||||
2370 | use_temp = False |
|
2346 | use_temp = False | |
2371 | elif args: |
|
2347 | elif args: | |
2372 | # Mode where user specifies ranges of lines, like in %macro. |
|
2348 | # Mode where user specifies ranges of lines, like in %macro. | |
2373 | data = self.extract_input_lines(args, opts_raw) |
|
2349 | data = self.shell.extract_input_lines(args, opts_raw) | |
2374 | if not data: |
|
2350 | if not data: | |
2375 | try: |
|
2351 | try: | |
2376 | # Load the parameter given as a variable. If not a string, |
|
2352 | # Load the parameter given as a variable. If not a string, |
General Comments 0
You need to be logged in to leave comments.
Login now