Return as a string a set of input history slices. Parameters ---------- range_str : str The set of slices is given as a string, like "~5/6-~4/2 4:8 9", since this function is for use by magic functions which get their arguments as strings.
(self, range_str, raw=False)
| 3969 | page.page(IPython.core.usage.interactive_usage) |
| 3970 | |
| 3971 | def extract_input_lines(self, range_str, raw=False): |
| 3972 | """Return as a string a set of input history slices. |
| 3973 | |
| 3974 | Parameters |
| 3975 | ---------- |
| 3976 | range_str : str |
| 3977 | The set of slices is given as a string, like "~5/6-~4/2 4:8 9", |
| 3978 | since this function is for use by magic functions which get their |
| 3979 | arguments as strings. The number before the / is the session |
| 3980 | number: ~n goes n back from the current session. |
| 3981 | |
| 3982 | If empty string is given, returns history of current session |
| 3983 | without the last input. |
| 3984 | |
| 3985 | raw : bool, optional |
| 3986 | By default, the processed input is used. If this is true, the raw |
| 3987 | input history is used instead. |
| 3988 | |
| 3989 | Notes |
| 3990 | ----- |
| 3991 | Slices can be described with two notations: |
| 3992 | |
| 3993 | * ``N:M`` -> standard python form, means including items N...(M-1). |
| 3994 | * ``N-M`` -> include items N..M (closed endpoint). |
| 3995 | """ |
| 3996 | lines = self.history_manager.get_range_by_str(range_str, raw=raw) |
| 3997 | text = "\n".join(x for _, _, x in lines) |
| 3998 | |
| 3999 | # Skip the last line, as it's probably the magic that called this |
| 4000 | if not range_str: |
| 4001 | if "\n" not in text: |
| 4002 | text = "" |
| 4003 | else: |
| 4004 | text = text[: text.rfind("\n")] |
| 4005 | |
| 4006 | return text |
| 4007 | |
| 4008 | def find_user_code(self, target, raw=True, py_only=False, skip_encoding_cookie=True, search_ns=False): |
| 4009 | """Get a code string from history, file, url, or a string or macro. |
no test coverage detected