Show More
@@ -462,7 +462,7 b' def _deduplicate_completions(text: str, completions: _IC)-> _IC:' | |||||
462 | seen.add(new_text) |
|
462 | seen.add(new_text) | |
463 |
|
463 | |||
464 |
|
464 | |||
465 | def rectify_completions(text: str, completions: _IC, *, _debug=False)->_IC: |
|
465 | def rectify_completions(text: str, completions: _IC, *, _debug: bool = False) -> _IC: | |
466 | """ |
|
466 | """ | |
467 | Rectify a set of completions to all have the same ``start`` and ``end`` |
|
467 | Rectify a set of completions to all have the same ``start`` and ``end`` | |
468 |
|
468 | |||
@@ -479,6 +479,8 b' def rectify_completions(text: str, completions: _IC, *, _debug=False)->_IC:' | |||||
479 | text that should be completed. |
|
479 | text that should be completed. | |
480 | completions : Iterator[Completion] |
|
480 | completions : Iterator[Completion] | |
481 | iterator over the completions to rectify |
|
481 | iterator over the completions to rectify | |
|
482 | _debug : bool | |||
|
483 | Log failed completion | |||
482 |
|
484 | |||
483 | Notes |
|
485 | Notes | |
484 | ----- |
|
486 | ----- | |
@@ -1128,16 +1130,22 b' class IPCompleter(Completer):' | |||||
1128 | secondary optional dict for completions, to |
|
1130 | secondary optional dict for completions, to | |
1129 | handle cases (such as IPython embedded inside functions) where |
|
1131 | handle cases (such as IPython embedded inside functions) where | |
1130 | both Python scopes are visible. |
|
1132 | both Python scopes are visible. | |
1131 | use_readline : bool, optional |
|
1133 | config : Config | |
1132 | DEPRECATED, ignored since IPython 6.0, will have no effects |
|
1134 | traitlet's config object | |
|
1135 | **kwargs | |||
|
1136 | passed to super class unmodified. | |||
1133 | """ |
|
1137 | """ | |
1134 |
|
1138 | |||
1135 | self.magic_escape = ESC_MAGIC |
|
1139 | self.magic_escape = ESC_MAGIC | |
1136 | self.splitter = CompletionSplitter() |
|
1140 | self.splitter = CompletionSplitter() | |
1137 |
|
1141 | |||
1138 | # _greedy_changed() depends on splitter and readline being defined: |
|
1142 | # _greedy_changed() depends on splitter and readline being defined: | |
1139 | Completer.__init__(self, namespace=namespace, global_namespace=global_namespace, |
|
1143 | super().__init__( | |
1140 | config=config, **kwargs) |
|
1144 | namespace=namespace, | |
|
1145 | global_namespace=global_namespace, | |||
|
1146 | config=config, | |||
|
1147 | **kwargs | |||
|
1148 | ) | |||
1141 |
|
1149 | |||
1142 | # List where completion matches will be stored |
|
1150 | # List where completion matches will be stored | |
1143 | self.matches = [] |
|
1151 | self.matches = [] | |
@@ -2055,9 +2063,9 b' class IPCompleter(Completer):' | |||||
2055 |
|
2063 | |||
2056 | Parameters |
|
2064 | Parameters | |
2057 | ---------- |
|
2065 | ---------- | |
2058 |
cursor_line |
|
2066 | cursor_line | |
2059 | Index of the line the cursor is on. 0 indexed. |
|
2067 | Index of the line the cursor is on. 0 indexed. | |
2060 |
cursor_pos |
|
2068 | cursor_pos | |
2061 | Position of the cursor in the current line/line_buffer/text. 0 |
|
2069 | Position of the cursor in the current line/line_buffer/text. 0 | |
2062 | indexed. |
|
2070 | indexed. | |
2063 | line_buffer : optional, str |
|
2071 | line_buffer : optional, str |
@@ -32,6 +32,8 b' from IPython.utils.py3compat import input' | |||||
32 |
|
32 | |||
33 | from IPython.core.release import __version__ as version |
|
33 | from IPython.core.release import __version__ as version | |
34 |
|
34 | |||
|
35 | from typing import Optional | |||
|
36 | ||||
35 | #----------------------------------------------------------------------------- |
|
37 | #----------------------------------------------------------------------------- | |
36 | # Code |
|
38 | # Code | |
37 | #----------------------------------------------------------------------------- |
|
39 | #----------------------------------------------------------------------------- | |
@@ -95,8 +97,15 b' class CrashHandler(object):' | |||||
95 | message_template = _default_message_template |
|
97 | message_template = _default_message_template | |
96 | section_sep = '\n\n'+'*'*75+'\n\n' |
|
98 | section_sep = '\n\n'+'*'*75+'\n\n' | |
97 |
|
99 | |||
98 | def __init__(self, app, contact_name=None, contact_email=None, |
|
100 | def __init__( | |
99 | bug_tracker=None, show_crash_traceback=True, call_pdb=False): |
|
101 | self, | |
|
102 | app, | |||
|
103 | contact_name: Optional[str] = None, | |||
|
104 | contact_email: Optional[str] = None, | |||
|
105 | bug_tracker: Optional[str] = None, | |||
|
106 | show_crash_traceback: bool = True, | |||
|
107 | call_pdb: bool = False, | |||
|
108 | ): | |||
100 | """Create a new crash handler |
|
109 | """Create a new crash handler | |
101 |
|
110 | |||
102 | Parameters |
|
111 | Parameters | |
@@ -113,10 +122,15 b' class CrashHandler(object):' | |||||
113 | show_crash_traceback : bool |
|
122 | show_crash_traceback : bool | |
114 | If false, don't print the crash traceback on stderr, only generate |
|
123 | If false, don't print the crash traceback on stderr, only generate | |
115 | the on-disk report |
|
124 | the on-disk report | |
116 | Non-argument instance attributes |
|
125 | call_pdb | |
|
126 | Whether to call pdb on crash | |||
|
127 | ||||
|
128 | Attributes | |||
|
129 | ---------- | |||
117 | These instances contain some non-argument attributes which allow for |
|
130 | These instances contain some non-argument attributes which allow for | |
118 | further customization of the crash handler's behavior. Please see the |
|
131 | further customization of the crash handler's behavior. Please see the | |
119 | source for further details. |
|
132 | source for further details. | |
|
133 | ||||
120 | """ |
|
134 | """ | |
121 | self.crash_report_fname = "Crash_report_%s.txt" % app.name |
|
135 | self.crash_report_fname = "Crash_report_%s.txt" % app.name | |
122 | self.app = app |
|
136 | self.app = app |
@@ -798,7 +798,6 b' class Pdb(OldPdb):' | |||||
798 |
|
798 | |||
799 | def break_anywhere(self, frame): |
|
799 | def break_anywhere(self, frame): | |
800 | """ |
|
800 | """ | |
801 |
|
||||
802 | _stop_in_decorator_internals is overly restrictive, as we may still want |
|
801 | _stop_in_decorator_internals is overly restrictive, as we may still want | |
803 | to trace function calls, so we need to also update break_anywhere so |
|
802 | to trace function calls, so we need to also update break_anywhere so | |
804 | that is we don't `stop_here`, because of debugger skip, we may still |
|
803 | that is we don't `stop_here`, because of debugger skip, we may still | |
@@ -820,8 +819,6 b' class Pdb(OldPdb):' | |||||
820 | """ |
|
819 | """ | |
821 | Utility to tell us whether we are in a decorator internal and should stop. |
|
820 | Utility to tell us whether we are in a decorator internal and should stop. | |
822 |
|
821 | |||
823 |
|
||||
824 |
|
||||
825 | """ |
|
822 | """ | |
826 |
|
823 | |||
827 | # if we are disabled don't skip |
|
824 | # if we are disabled don't skip |
@@ -826,15 +826,19 b' class Image(DisplayObject):' | |||||
826 | data : unicode, str or bytes |
|
826 | data : unicode, str or bytes | |
827 | The raw image data or a URL or filename to load the data from. |
|
827 | The raw image data or a URL or filename to load the data from. | |
828 | This always results in embedded image data. |
|
828 | This always results in embedded image data. | |
|
829 | ||||
829 | url : unicode |
|
830 | url : unicode | |
830 | A URL to download the data from. If you specify `url=`, |
|
831 | A URL to download the data from. If you specify `url=`, | |
831 | the image data will not be embedded unless you also specify `embed=True`. |
|
832 | the image data will not be embedded unless you also specify `embed=True`. | |
|
833 | ||||
832 | filename : unicode |
|
834 | filename : unicode | |
833 | Path to a local file to load the data from. |
|
835 | Path to a local file to load the data from. | |
834 | Images from a file are always embedded. |
|
836 | Images from a file are always embedded. | |
|
837 | ||||
835 | format : unicode |
|
838 | format : unicode | |
836 | The format of the image data (png/jpeg/jpg/gif). If a filename or URL is given |
|
839 | The format of the image data (png/jpeg/jpg/gif). If a filename or URL is given | |
837 | for format will be inferred from the filename extension. |
|
840 | for format will be inferred from the filename extension. | |
|
841 | ||||
838 | embed : bool |
|
842 | embed : bool | |
839 | Should the image data be embedded using a data URI (True) or be |
|
843 | Should the image data be embedded using a data URI (True) or be | |
840 | loaded using an <img> tag. Set this to True if you want the image |
|
844 | loaded using an <img> tag. Set this to True if you want the image | |
@@ -844,10 +848,13 b' class Image(DisplayObject):' | |||||
844 | default value is `False`. |
|
848 | default value is `False`. | |
845 |
|
849 | |||
846 | Note that QtConsole is not able to display images if `embed` is set to `False` |
|
850 | Note that QtConsole is not able to display images if `embed` is set to `False` | |
|
851 | ||||
847 | width : int |
|
852 | width : int | |
848 | Width in pixels to which to constrain the image in html |
|
853 | Width in pixels to which to constrain the image in html | |
|
854 | ||||
849 | height : int |
|
855 | height : int | |
850 | Height in pixels to which to constrain the image in html |
|
856 | Height in pixels to which to constrain the image in html | |
|
857 | ||||
851 | retina : bool |
|
858 | retina : bool | |
852 | Automatically set the width and height to half of the measured |
|
859 | Automatically set the width and height to half of the measured | |
853 | width and height. |
|
860 | width and height. | |
@@ -855,10 +862,13 b' class Image(DisplayObject):' | |||||
855 | from image data. |
|
862 | from image data. | |
856 | For non-embedded images, you can just set the desired display width |
|
863 | For non-embedded images, you can just set the desired display width | |
857 | and height directly. |
|
864 | and height directly. | |
|
865 | ||||
858 | unconfined : bool |
|
866 | unconfined : bool | |
859 | Set unconfined=True to disable max-width confinement of the image. |
|
867 | Set unconfined=True to disable max-width confinement of the image. | |
|
868 | ||||
860 | metadata : dict |
|
869 | metadata : dict | |
861 | Specify extra metadata to attach to the image. |
|
870 | Specify extra metadata to attach to the image. | |
|
871 | ||||
862 | alt : unicode |
|
872 | alt : unicode | |
863 | Alternative text for the image, for use by screen readers. |
|
873 | Alternative text for the image, for use by screen readers. | |
864 |
|
874 | |||
@@ -1067,12 +1077,15 b' class Video(DisplayObject):' | |||||
1067 | data : unicode, str or bytes |
|
1077 | data : unicode, str or bytes | |
1068 | The raw video data or a URL or filename to load the data from. |
|
1078 | The raw video data or a URL or filename to load the data from. | |
1069 | Raw data will require passing ``embed=True``. |
|
1079 | Raw data will require passing ``embed=True``. | |
|
1080 | ||||
1070 | url : unicode |
|
1081 | url : unicode | |
1071 | A URL for the video. If you specify ``url=``, |
|
1082 | A URL for the video. If you specify ``url=``, | |
1072 | the image data will not be embedded. |
|
1083 | the image data will not be embedded. | |
|
1084 | ||||
1073 | filename : unicode |
|
1085 | filename : unicode | |
1074 | Path to a local file containing the video. |
|
1086 | Path to a local file containing the video. | |
1075 | Will be interpreted as a local URL unless ``embed=True``. |
|
1087 | Will be interpreted as a local URL unless ``embed=True``. | |
|
1088 | ||||
1076 | embed : bool |
|
1089 | embed : bool | |
1077 | Should the video be embedded using a data URI (True) or be |
|
1090 | Should the video be embedded using a data URI (True) or be | |
1078 | loaded using a <video> tag (False). |
|
1091 | loaded using a <video> tag (False). | |
@@ -1083,15 +1096,19 b' class Video(DisplayObject):' | |||||
1083 | Local files can be displayed with URLs without embedding the content, via:: |
|
1096 | Local files can be displayed with URLs without embedding the content, via:: | |
1084 |
|
1097 | |||
1085 | Video('./video.mp4') |
|
1098 | Video('./video.mp4') | |
|
1099 | ||||
1086 | mimetype : unicode |
|
1100 | mimetype : unicode | |
1087 | Specify the mimetype for embedded videos. |
|
1101 | Specify the mimetype for embedded videos. | |
1088 | Default will be guessed from file extension, if available. |
|
1102 | Default will be guessed from file extension, if available. | |
|
1103 | ||||
1089 | width : int |
|
1104 | width : int | |
1090 | Width in pixels to which to constrain the video in HTML. |
|
1105 | Width in pixels to which to constrain the video in HTML. | |
1091 | If not supplied, defaults to the width of the video. |
|
1106 | If not supplied, defaults to the width of the video. | |
|
1107 | ||||
1092 | height : int |
|
1108 | height : int | |
1093 | Height in pixels to which to constrain the video in html. |
|
1109 | Height in pixels to which to constrain the video in html. | |
1094 | If not supplied, defaults to the height of the video. |
|
1110 | If not supplied, defaults to the height of the video. | |
|
1111 | ||||
1095 | html_attributes : str |
|
1112 | html_attributes : str | |
1096 | Attributes for the HTML ``<video>`` block. |
|
1113 | Attributes for the HTML ``<video>`` block. | |
1097 | Default: ``"controls"`` to get video controls. |
|
1114 | Default: ``"controls"`` to get video controls. | |
@@ -1221,7 +1238,6 b' def set_matplotlib_close(close=True):' | |||||
1221 |
|
1238 | |||
1222 | use `matplotlib_inline.backend_inline.set_matplotlib_close()` |
|
1239 | use `matplotlib_inline.backend_inline.set_matplotlib_close()` | |
1223 |
|
1240 | |||
1224 |
|
||||
1225 | Set whether the inline backend closes all figures automatically or not. |
|
1241 | Set whether the inline backend closes all figures automatically or not. | |
1226 |
|
1242 | |||
1227 | By default, the inline backend used in the IPython Notebook will close all |
|
1243 | By default, the inline backend used in the IPython Notebook will close all |
@@ -433,6 +433,7 b' class BaseFormatter(Configurable):' | |||||
433 | ---------- |
|
433 | ---------- | |
434 | typ : type or '__module__.__name__' string for a type |
|
434 | typ : type or '__module__.__name__' string for a type | |
435 | The class of the object that will be formatted using `func`. |
|
435 | The class of the object that will be formatted using `func`. | |
|
436 | ||||
436 | func : callable |
|
437 | func : callable | |
437 | A callable for computing the format data. |
|
438 | A callable for computing the format data. | |
438 | `func` will be called with the object to be formatted, |
|
439 | `func` will be called with the object to be formatted, | |
@@ -474,8 +475,10 b' class BaseFormatter(Configurable):' | |||||
474 | type_module : str |
|
475 | type_module : str | |
475 | The full dotted name of the module the type is defined in, like |
|
476 | The full dotted name of the module the type is defined in, like | |
476 | ``numpy``. |
|
477 | ``numpy``. | |
|
478 | ||||
477 | type_name : str |
|
479 | type_name : str | |
478 | The name of the type (the class name), like ``dtype`` |
|
480 | The name of the type (the class name), like ``dtype`` | |
|
481 | ||||
479 | func : callable |
|
482 | func : callable | |
480 | A callable for computing the format data. |
|
483 | A callable for computing the format data. | |
481 | `func` will be called with the object to be formatted, |
|
484 | `func` will be called with the object to be formatted, |
@@ -16,7 +16,7 b'' | |||||
16 |
|
16 | |||
17 | def get_ipython(): |
|
17 | def get_ipython(): | |
18 | """Get the global InteractiveShell instance. |
|
18 | """Get the global InteractiveShell instance. | |
19 |
|
19 | |||
20 | Returns None if no InteractiveShell instance is registered. |
|
20 | Returns None if no InteractiveShell instance is registered. | |
21 | """ |
|
21 | """ | |
22 | from IPython.core.interactiveshell import InteractiveShell |
|
22 | from IPython.core.interactiveshell import InteractiveShell |
@@ -195,12 +195,12 b' class HistoryAccessor(HistoryAccessorBase):' | |||||
195 | Parameters |
|
195 | Parameters | |
196 | ---------- |
|
196 | ---------- | |
197 | profile : str |
|
197 | profile : str | |
198 | The name of the profile from which to open history. |
|
198 | The name of the profile from which to open history. | |
199 | hist_file : str |
|
199 | hist_file : str | |
200 | Path to an SQLite history database stored by IPython. If specified, |
|
200 | Path to an SQLite history database stored by IPython. If specified, | |
201 | hist_file overrides profile. |
|
201 | hist_file overrides profile. | |
202 | config : :class:`~traitlets.config.loader.Config` |
|
202 | config : :class:`~traitlets.config.loader.Config` | |
203 | Config object. hist_file can also be set through this. |
|
203 | Config object. hist_file can also be set through this. | |
204 | """ |
|
204 | """ | |
205 | # We need a pointer back to the shell for various tasks. |
|
205 | # We need a pointer back to the shell for various tasks. | |
206 | super(HistoryAccessor, self).__init__(**traits) |
|
206 | super(HistoryAccessor, self).__init__(**traits) | |
@@ -227,7 +227,7 b' class HistoryAccessor(HistoryAccessorBase):' | |||||
227 | Parameters |
|
227 | Parameters | |
228 | ---------- |
|
228 | ---------- | |
229 | profile : str |
|
229 | profile : str | |
230 | The name of a profile which has a history file. |
|
230 | The name of a profile which has a history file. | |
231 | """ |
|
231 | """ | |
232 | return Path(locate_profile(profile)) / "history.sqlite" |
|
232 | return Path(locate_profile(profile)) / "history.sqlite" | |
233 |
|
233 | |||
@@ -271,13 +271,13 b' class HistoryAccessor(HistoryAccessorBase):' | |||||
271 | Parameters |
|
271 | Parameters | |
272 | ---------- |
|
272 | ---------- | |
273 | sql : str |
|
273 | sql : str | |
274 | Any filtering expressions to go after SELECT ... FROM ... |
|
274 | Any filtering expressions to go after SELECT ... FROM ... | |
275 | params : tuple |
|
275 | params : tuple | |
276 | Parameters passed to the SQL query (to replace "?") |
|
276 | Parameters passed to the SQL query (to replace "?") | |
277 | raw, output : bool |
|
277 | raw, output : bool | |
278 | See :meth:`get_range` |
|
278 | See :meth:`get_range` | |
279 | latest : bool |
|
279 | latest : bool | |
280 | Select rows with max (session, line) |
|
280 | Select rows with max (session, line) | |
281 |
|
281 | |||
282 | Returns |
|
282 | Returns | |
283 | ------- |
|
283 | ------- | |
@@ -305,23 +305,21 b' class HistoryAccessor(HistoryAccessorBase):' | |||||
305 |
|
305 | |||
306 | Parameters |
|
306 | Parameters | |
307 | ---------- |
|
307 | ---------- | |
308 |
|
||||
309 | session : int |
|
308 | session : int | |
310 | Session number to retrieve. |
|
309 | Session number to retrieve. | |
311 |
|
310 | |||
312 | Returns |
|
311 | Returns | |
313 | ------- |
|
312 | ------- | |
314 |
|
||||
315 | session_id : int |
|
313 | session_id : int | |
316 | Session ID number |
|
314 | Session ID number | |
317 | start : datetime |
|
315 | start : datetime | |
318 | Timestamp for the start of the session. |
|
316 | Timestamp for the start of the session. | |
319 | end : datetime |
|
317 | end : datetime | |
320 | Timestamp for the end of the session, or None if IPython crashed. |
|
318 | Timestamp for the end of the session, or None if IPython crashed. | |
321 | num_cmds : int |
|
319 | num_cmds : int | |
322 | Number of commands run, or None if IPython crashed. |
|
320 | Number of commands run, or None if IPython crashed. | |
323 | remark : unicode |
|
321 | remark : unicode | |
324 | A manually set description. |
|
322 | A manually set description. | |
325 | """ |
|
323 | """ | |
326 | query = "SELECT * from sessions where session == ?" |
|
324 | query = "SELECT * from sessions where session == ?" | |
327 | return self.db.execute(query, (session,)).fetchone() |
|
325 | return self.db.execute(query, (session,)).fetchone() | |
@@ -343,13 +341,13 b' class HistoryAccessor(HistoryAccessorBase):' | |||||
343 | Parameters |
|
341 | Parameters | |
344 | ---------- |
|
342 | ---------- | |
345 | n : int |
|
343 | n : int | |
346 | The number of lines to get |
|
344 | The number of lines to get | |
347 | raw, output : bool |
|
345 | raw, output : bool | |
348 | See :meth:`get_range` |
|
346 | See :meth:`get_range` | |
349 | include_latest : bool |
|
347 | include_latest : bool | |
350 | If False (default), n+1 lines are fetched, and the latest one |
|
348 | If False (default), n+1 lines are fetched, and the latest one | |
351 | is discarded. This is intended to be used where the function |
|
349 | is discarded. This is intended to be used where the function | |
352 | is called by a user command, which it should not return. |
|
350 | is called by a user command, which it should not return. | |
353 |
|
351 | |||
354 | Returns |
|
352 | Returns | |
355 | ------- |
|
353 | ------- | |
@@ -373,16 +371,16 b' class HistoryAccessor(HistoryAccessorBase):' | |||||
373 | Parameters |
|
371 | Parameters | |
374 | ---------- |
|
372 | ---------- | |
375 | pattern : str |
|
373 | pattern : str | |
376 | The wildcarded pattern to match when searching |
|
374 | The wildcarded pattern to match when searching | |
377 | search_raw : bool |
|
375 | search_raw : bool | |
378 | If True, search the raw input, otherwise, the parsed input |
|
376 | If True, search the raw input, otherwise, the parsed input | |
379 | raw, output : bool |
|
377 | raw, output : bool | |
380 | See :meth:`get_range` |
|
378 | See :meth:`get_range` | |
381 | n : None or int |
|
379 | n : None or int | |
382 | If an integer is given, it defines the limit of |
|
380 | If an integer is given, it defines the limit of | |
383 | returned entries. |
|
381 | returned entries. | |
384 | unique : bool |
|
382 | unique : bool | |
385 | When it is true, return only unique entries. |
|
383 | When it is true, return only unique entries. | |
386 |
|
384 | |||
387 | Returns |
|
385 | Returns | |
388 | ------- |
|
386 | ------- | |
@@ -430,9 +428,9 b' class HistoryAccessor(HistoryAccessorBase):' | |||||
430 | Returns |
|
428 | Returns | |
431 | ------- |
|
429 | ------- | |
432 | entries |
|
430 | entries | |
433 | An iterator over the desired lines. Each line is a 3-tuple, either |
|
431 | An iterator over the desired lines. Each line is a 3-tuple, either | |
434 | (session, line, input) if output is False, or |
|
432 | (session, line, input) if output is False, or | |
435 | (session, line, (input, output)) if output is True. |
|
433 | (session, line, (input, output)) if output is True. | |
436 | """ |
|
434 | """ | |
437 | if stop: |
|
435 | if stop: | |
438 | lineclause = "line >= ? AND line < ?" |
|
436 | lineclause = "line >= ? AND line < ?" | |
@@ -451,13 +449,13 b' class HistoryAccessor(HistoryAccessorBase):' | |||||
451 | Parameters |
|
449 | Parameters | |
452 | ---------- |
|
450 | ---------- | |
453 | rangestr : str |
|
451 | rangestr : str | |
454 | A string specifying ranges, e.g. "5 ~2/1-4". If empty string is used, |
|
452 | A string specifying ranges, e.g. "5 ~2/1-4". If empty string is used, | |
455 | this will return everything from current session's history. |
|
453 | this will return everything from current session's history. | |
456 |
|
454 | |||
457 | See the documentation of :func:`%history` for the full details. |
|
455 | See the documentation of :func:`%history` for the full details. | |
458 |
|
456 | |||
459 | raw, output : bool |
|
457 | raw, output : bool | |
460 | As :meth:`get_range` |
|
458 | As :meth:`get_range` | |
461 |
|
459 | |||
462 | Returns |
|
460 | Returns | |
463 | ------- |
|
461 | ------- | |
@@ -605,24 +603,22 b' class HistoryManager(HistoryAccessor):' | |||||
605 |
|
603 | |||
606 | Parameters |
|
604 | Parameters | |
607 | ---------- |
|
605 | ---------- | |
608 |
|
||||
609 | session : int |
|
606 | session : int | |
610 | Session number to retrieve. The current session is 0, and negative |
|
607 | Session number to retrieve. The current session is 0, and negative | |
611 | numbers count back from current session, so -1 is the previous session. |
|
608 | numbers count back from current session, so -1 is the previous session. | |
612 |
|
609 | |||
613 | Returns |
|
610 | Returns | |
614 | ------- |
|
611 | ------- | |
615 |
|
||||
616 | session_id : int |
|
612 | session_id : int | |
617 | Session ID number |
|
613 | Session ID number | |
618 | start : datetime |
|
614 | start : datetime | |
619 | Timestamp for the start of the session. |
|
615 | Timestamp for the start of the session. | |
620 | end : datetime |
|
616 | end : datetime | |
621 | Timestamp for the end of the session, or None if IPython crashed. |
|
617 | Timestamp for the end of the session, or None if IPython crashed. | |
622 | num_cmds : int |
|
618 | num_cmds : int | |
623 | Number of commands run, or None if IPython crashed. |
|
619 | Number of commands run, or None if IPython crashed. | |
624 | remark : unicode |
|
620 | remark : unicode | |
625 | A manually set description. |
|
621 | A manually set description. | |
626 | """ |
|
622 | """ | |
627 | if session <= 0: |
|
623 | if session <= 0: | |
628 | session += self.session_number |
|
624 | session += self.session_number | |
@@ -673,9 +669,9 b' class HistoryManager(HistoryAccessor):' | |||||
673 | Returns |
|
669 | Returns | |
674 | ------- |
|
670 | ------- | |
675 | entries |
|
671 | entries | |
676 | An iterator over the desired lines. Each line is a 3-tuple, either |
|
672 | An iterator over the desired lines. Each line is a 3-tuple, either | |
677 | (session, line, input) if output is False, or |
|
673 | (session, line, input) if output is False, or | |
678 | (session, line, (input, output)) if output is True. |
|
674 | (session, line, (input, output)) if output is True. | |
679 | """ |
|
675 | """ | |
680 | if session <= 0: |
|
676 | if session <= 0: | |
681 | session += self.session_number |
|
677 | session += self.session_number | |
@@ -694,14 +690,12 b' class HistoryManager(HistoryAccessor):' | |||||
694 | Parameters |
|
690 | Parameters | |
695 | ---------- |
|
691 | ---------- | |
696 | line_num : int |
|
692 | line_num : int | |
697 | The prompt number of this input. |
|
693 | The prompt number of this input. | |
698 |
|
||||
699 | source : str |
|
694 | source : str | |
700 | Python input. |
|
695 | Python input. | |
701 |
|
||||
702 | source_raw : str, optional |
|
696 | source_raw : str, optional | |
703 | If given, this is the raw input without any IPython transformations |
|
697 | If given, this is the raw input without any IPython transformations | |
704 | applied to it. If not given, ``source`` is used. |
|
698 | applied to it. If not given, ``source`` is used. | |
705 | """ |
|
699 | """ | |
706 | if source_raw is None: |
|
700 | if source_raw is None: | |
707 | source_raw = source |
|
701 | source_raw = source | |
@@ -745,7 +739,7 b' class HistoryManager(HistoryAccessor):' | |||||
745 | Parameters |
|
739 | Parameters | |
746 | ---------- |
|
740 | ---------- | |
747 | line_num : int |
|
741 | line_num : int | |
748 | The line number from which to save outputs |
|
742 | The line number from which to save outputs | |
749 | """ |
|
743 | """ | |
750 | if (not self.db_log_output) or (line_num not in self.output_hist_reprs): |
|
744 | if (not self.db_log_output) or (line_num not in self.output_hist_reprs): | |
751 | return |
|
745 | return |
@@ -210,7 +210,7 b' def last_blank(src):' | |||||
210 | Parameters |
|
210 | Parameters | |
211 | ---------- |
|
211 | ---------- | |
212 | src : string |
|
212 | src : string | |
213 | A single or multiline string. |
|
213 | A single or multiline string. | |
214 | """ |
|
214 | """ | |
215 | if not src: return False |
|
215 | if not src: return False | |
216 | ll = src.splitlines()[-1] |
|
216 | ll = src.splitlines()[-1] | |
@@ -228,7 +228,7 b' def last_two_blanks(src):' | |||||
228 | Parameters |
|
228 | Parameters | |
229 | ---------- |
|
229 | ---------- | |
230 | src : string |
|
230 | src : string | |
231 | A single or multiline string. |
|
231 | A single or multiline string. | |
232 | """ |
|
232 | """ | |
233 | if not src: return False |
|
233 | if not src: return False | |
234 | # The logic here is tricky: I couldn't get a regexp to work and pass all |
|
234 | # The logic here is tricky: I couldn't get a regexp to work and pass all | |
@@ -251,7 +251,7 b' def remove_comments(src):' | |||||
251 | Parameters |
|
251 | Parameters | |
252 | ---------- |
|
252 | ---------- | |
253 | src : string |
|
253 | src : string | |
254 | A single or multiline input string. |
|
254 | A single or multiline input string. | |
255 |
|
255 | |||
256 | Returns |
|
256 | Returns | |
257 | ------- |
|
257 | ------- | |
@@ -351,22 +351,22 b' class InputSplitter(object):' | |||||
351 |
|
351 | |||
352 | def check_complete(self, source): |
|
352 | def check_complete(self, source): | |
353 | """Return whether a block of code is ready to execute, or should be continued |
|
353 | """Return whether a block of code is ready to execute, or should be continued | |
354 |
|
354 | |||
355 | This is a non-stateful API, and will reset the state of this InputSplitter. |
|
355 | This is a non-stateful API, and will reset the state of this InputSplitter. | |
356 |
|
356 | |||
357 | Parameters |
|
357 | Parameters | |
358 | ---------- |
|
358 | ---------- | |
359 | source : string |
|
359 | source : string | |
360 | Python input code, which can be multiline. |
|
360 | Python input code, which can be multiline. | |
361 |
|
361 | |||
362 | Returns |
|
362 | Returns | |
363 | ------- |
|
363 | ------- | |
364 | status : str |
|
364 | status : str | |
365 | One of 'complete', 'incomplete', or 'invalid' if source is not a |
|
365 | One of 'complete', 'incomplete', or 'invalid' if source is not a | |
366 | prefix of valid code. |
|
366 | prefix of valid code. | |
367 | indent_spaces : int or None |
|
367 | indent_spaces : int or None | |
368 | The number of spaces by which to indent the next line of code. If |
|
368 | The number of spaces by which to indent the next line of code. If | |
369 | status is not 'incomplete', this is None. |
|
369 | status is not 'incomplete', this is None. | |
370 | """ |
|
370 | """ | |
371 | self.reset() |
|
371 | self.reset() | |
372 | try: |
|
372 | try: | |
@@ -397,15 +397,15 b' class InputSplitter(object):' | |||||
397 | Parameters |
|
397 | Parameters | |
398 | ---------- |
|
398 | ---------- | |
399 | lines : string |
|
399 | lines : string | |
400 | One or more lines of Python input. |
|
400 | One or more lines of Python input. | |
401 |
|
401 | |||
402 | Returns |
|
402 | Returns | |
403 | ------- |
|
403 | ------- | |
404 | is_complete : boolean |
|
404 | is_complete : boolean | |
405 | True if the current input source (the result of the current input |
|
405 | True if the current input source (the result of the current input | |
406 | plus prior inputs) forms a complete Python execution block. Note that |
|
406 | plus prior inputs) forms a complete Python execution block. Note that | |
407 | this value is also stored as a private attribute (``_is_complete``), so it |
|
407 | this value is also stored as a private attribute (``_is_complete``), so it | |
408 | can be queried at any time. |
|
408 | can be queried at any time. | |
409 | """ |
|
409 | """ | |
410 | assert isinstance(lines, str) |
|
410 | assert isinstance(lines, str) | |
411 | self._store(lines) |
|
411 | self._store(lines) | |
@@ -448,7 +448,7 b' class InputSplitter(object):' | |||||
448 | guess whether a block is complete or not based solely on prior and |
|
448 | guess whether a block is complete or not based solely on prior and | |
449 | current input lines. The InputSplitter considers it has a complete |
|
449 | current input lines. The InputSplitter considers it has a complete | |
450 | interactive block and will not accept more input when either: |
|
450 | interactive block and will not accept more input when either: | |
451 |
|
451 | |||
452 | * A SyntaxError is raised |
|
452 | * A SyntaxError is raised | |
453 |
|
453 | |||
454 | * The code is complete and consists of a single line or a single |
|
454 | * The code is complete and consists of a single line or a single | |
@@ -618,9 +618,9 b' class IPythonInputSplitter(InputSplitter):' | |||||
618 | def flush_transformers(self): |
|
618 | def flush_transformers(self): | |
619 | def _flush(transform, outs): |
|
619 | def _flush(transform, outs): | |
620 | """yield transformed lines |
|
620 | """yield transformed lines | |
621 |
|
621 | |||
622 | always strings, never None |
|
622 | always strings, never None | |
623 |
|
623 | |||
624 | transform: the current transform |
|
624 | transform: the current transform | |
625 | outs: an iterable of previously transformed inputs. |
|
625 | outs: an iterable of previously transformed inputs. | |
626 | Each may be multiline, which will be passed |
|
626 | Each may be multiline, which will be passed | |
@@ -690,15 +690,15 b' class IPythonInputSplitter(InputSplitter):' | |||||
690 | Parameters |
|
690 | Parameters | |
691 | ---------- |
|
691 | ---------- | |
692 | lines : string |
|
692 | lines : string | |
693 | One or more lines of Python input. |
|
693 | One or more lines of Python input. | |
694 |
|
694 | |||
695 | Returns |
|
695 | Returns | |
696 | ------- |
|
696 | ------- | |
697 | is_complete : boolean |
|
697 | is_complete : boolean | |
698 | True if the current input source (the result of the current input |
|
698 | True if the current input source (the result of the current input | |
699 | plus prior inputs) forms a complete Python execution block. Note that |
|
699 | plus prior inputs) forms a complete Python execution block. Note that | |
700 | this value is also stored as a private attribute (_is_complete), so it |
|
700 | this value is also stored as a private attribute (_is_complete), so it | |
701 | can be queried at any time. |
|
701 | can be queried at any time. | |
702 | """ |
|
702 | """ | |
703 | assert isinstance(lines, str) |
|
703 | assert isinstance(lines, str) | |
704 | # We must ensure all input is pure unicode |
|
704 | # We must ensure all input is pure unicode | |
@@ -728,10 +728,10 b' class IPythonInputSplitter(InputSplitter):' | |||||
728 |
|
728 | |||
729 | def _transform_line(self, line): |
|
729 | def _transform_line(self, line): | |
730 | """Push a line of input code through the various transformers. |
|
730 | """Push a line of input code through the various transformers. | |
731 |
|
731 | |||
732 | Returns any output from the transformers, or None if a transformer |
|
732 | Returns any output from the transformers, or None if a transformer | |
733 | is accumulating lines. |
|
733 | is accumulating lines. | |
734 |
|
734 | |||
735 | Sets self.transformer_accumulating as a side effect. |
|
735 | Sets self.transformer_accumulating as a side effect. | |
736 | """ |
|
736 | """ | |
737 | def _accumulating(dbg): |
|
737 | def _accumulating(dbg): |
@@ -46,7 +46,7 b' class InputTransformer(metaclass=abc.ABCMeta):' | |||||
46 | def push(self, line): |
|
46 | def push(self, line): | |
47 | """Send a line of input to the transformer, returning the transformed |
|
47 | """Send a line of input to the transformer, returning the transformed | |
48 | input or None if the transformer is waiting for more input. |
|
48 | input or None if the transformer is waiting for more input. | |
49 |
|
49 | |||
50 | Must be overridden by subclasses. |
|
50 | Must be overridden by subclasses. | |
51 |
|
51 | |||
52 | Implementations may raise ``SyntaxError`` if the input is invalid. No |
|
52 | Implementations may raise ``SyntaxError`` if the input is invalid. No | |
@@ -58,7 +58,7 b' class InputTransformer(metaclass=abc.ABCMeta):' | |||||
58 | def reset(self): |
|
58 | def reset(self): | |
59 | """Return, transformed any lines that the transformer has accumulated, |
|
59 | """Return, transformed any lines that the transformer has accumulated, | |
60 | and reset its internal state. |
|
60 | and reset its internal state. | |
61 |
|
61 | |||
62 | Must be overridden by subclasses. |
|
62 | Must be overridden by subclasses. | |
63 | """ |
|
63 | """ | |
64 | pass |
|
64 | pass | |
@@ -312,7 +312,7 b' def has_comment(src):' | |||||
312 | Parameters |
|
312 | Parameters | |
313 | ---------- |
|
313 | ---------- | |
314 | src : string |
|
314 | src : string | |
315 | A single line input string. |
|
315 | A single line input string. | |
316 |
|
316 | |||
317 | Returns |
|
317 | Returns | |
318 | ------- |
|
318 | ------- | |
@@ -324,11 +324,11 b' def has_comment(src):' | |||||
324 | def ends_in_comment_or_string(src): |
|
324 | def ends_in_comment_or_string(src): | |
325 | """Indicates whether or not an input line ends in a comment or within |
|
325 | """Indicates whether or not an input line ends in a comment or within | |
326 | a multiline string. |
|
326 | a multiline string. | |
327 |
|
327 | |||
328 | Parameters |
|
328 | Parameters | |
329 | ---------- |
|
329 | ---------- | |
330 | src : string |
|
330 | src : string | |
331 | A single line input string. |
|
331 | A single line input string. | |
332 |
|
332 | |||
333 | Returns |
|
333 | Returns | |
334 | ------- |
|
334 | ------- | |
@@ -358,7 +358,7 b' def help_end(line):' | |||||
358 | @CoroutineInputTransformer.wrap |
|
358 | @CoroutineInputTransformer.wrap | |
359 | def cellmagic(end_on_blank_line=False): |
|
359 | def cellmagic(end_on_blank_line=False): | |
360 | """Captures & transforms cell magics. |
|
360 | """Captures & transforms cell magics. | |
361 |
|
361 | |||
362 | After a cell magic is started, this stores up any lines it gets until it is |
|
362 | After a cell magic is started, this stores up any lines it gets until it is | |
363 | reset (sent None). |
|
363 | reset (sent None). | |
364 | """ |
|
364 | """ | |
@@ -397,7 +397,7 b' def cellmagic(end_on_blank_line=False):' | |||||
397 |
|
397 | |||
398 | def _strip_prompts(prompt_re, initial_re=None, turnoff_re=None): |
|
398 | def _strip_prompts(prompt_re, initial_re=None, turnoff_re=None): | |
399 | """Remove matching input prompts from a block of input. |
|
399 | """Remove matching input prompts from a block of input. | |
400 |
|
400 | |||
401 | Parameters |
|
401 | Parameters | |
402 | ---------- |
|
402 | ---------- | |
403 | prompt_re : regular expression |
|
403 | prompt_re : regular expression | |
@@ -407,7 +407,6 b' def _strip_prompts(prompt_re, initial_re=None, turnoff_re=None):' | |||||
407 | If no initial expression is given, prompt_re will be used everywhere. |
|
407 | If no initial expression is given, prompt_re will be used everywhere. | |
408 | Used mainly for plain Python prompts, where the continuation prompt |
|
408 | Used mainly for plain Python prompts, where the continuation prompt | |
409 | ``...`` is a valid Python expression in Python 3, so shouldn't be stripped. |
|
409 | ``...`` is a valid Python expression in Python 3, so shouldn't be stripped. | |
410 |
|
||||
411 | If initial_re and prompt_re differ, |
|
410 | If initial_re and prompt_re differ, | |
412 | only initial_re will be tested against the first line. |
|
411 | only initial_re will be tested against the first line. | |
413 | If any prompt is found on the first two lines, |
|
412 | If any prompt is found on the first two lines, | |
@@ -475,7 +474,7 b' def ipy_prompt():' | |||||
475 | @CoroutineInputTransformer.wrap |
|
474 | @CoroutineInputTransformer.wrap | |
476 | def leading_indent(): |
|
475 | def leading_indent(): | |
477 | """Remove leading indentation. |
|
476 | """Remove leading indentation. | |
478 |
|
477 | |||
479 | If the first line starts with a spaces or tabs, the same whitespace will be |
|
478 | If the first line starts with a spaces or tabs, the same whitespace will be | |
480 | removed from each following line until it is reset. |
|
479 | removed from each following line until it is reset. | |
481 | """ |
|
480 | """ |
@@ -640,17 +640,17 b' class TransformerManager:' | |||||
640 |
|
640 | |||
641 | Parameters |
|
641 | Parameters | |
642 | ---------- |
|
642 | ---------- | |
643 |
|
|
643 | cell : string | |
644 | Python input code, which can be multiline. |
|
644 | Python input code, which can be multiline. | |
645 |
|
645 | |||
646 | Returns |
|
646 | Returns | |
647 | ------- |
|
647 | ------- | |
648 | status : str |
|
648 | status : str | |
649 | One of 'complete', 'incomplete', or 'invalid' if source is not a |
|
649 | One of 'complete', 'incomplete', or 'invalid' if source is not a | |
650 | prefix of valid code. |
|
650 | prefix of valid code. | |
651 | indent_spaces : int or None |
|
651 | indent_spaces : int or None | |
652 | The number of spaces by which to indent the next line of code. If |
|
652 | The number of spaces by which to indent the next line of code. If | |
653 | status is not 'incomplete', this is None. |
|
653 | status is not 'incomplete', this is None. | |
654 | """ |
|
654 | """ | |
655 | # Remember if the lines ends in a new line. |
|
655 | # Remember if the lines ends in a new line. | |
656 | ends_with_newline = False |
|
656 | ends_with_newline = False |
@@ -1730,7 +1730,6 b' class InteractiveShell(SingletonConfigurable):' | |||||
1730 |
|
1730 | |||
1731 | Parameters |
|
1731 | Parameters | |
1732 | ---------- |
|
1732 | ---------- | |
1733 |
|
||||
1734 | exc_tuple : tuple of exception classes |
|
1733 | exc_tuple : tuple of exception classes | |
1735 | A *tuple* of exception classes, for which to call the defined |
|
1734 | A *tuple* of exception classes, for which to call the defined | |
1736 | handler. It is very important that you use a tuple, and NOT A |
|
1735 | handler. It is very important that you use a tuple, and NOT A | |
@@ -1760,7 +1759,6 b' class InteractiveShell(SingletonConfigurable):' | |||||
1760 |
|
1759 | |||
1761 | Notes |
|
1760 | Notes | |
1762 | ----- |
|
1761 | ----- | |
1763 |
|
||||
1764 | WARNING: by putting in your own exception handler into IPython's main |
|
1762 | WARNING: by putting in your own exception handler into IPython's main | |
1765 | execution loop, you run a very good chance of nasty crashes. This |
|
1763 | execution loop, you run a very good chance of nasty crashes. This | |
1766 | facility should only be used if you really know what you are doing. |
|
1764 | facility should only be used if you really know what you are doing. | |
@@ -1975,7 +1973,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
1975 |
|
1973 | |||
1976 | If the syntax error occurred when running a compiled code (i.e. running_compile_code=True), |
|
1974 | If the syntax error occurred when running a compiled code (i.e. running_compile_code=True), | |
1977 | longer stack trace will be displayed. |
|
1975 | longer stack trace will be displayed. | |
1978 |
|
|
1976 | """ | |
1979 | etype, value, last_traceback = self._get_exc_info() |
|
1977 | etype, value, last_traceback = self._get_exc_info() | |
1980 |
|
1978 | |||
1981 | if filename and issubclass(etype, SyntaxError): |
|
1979 | if filename and issubclass(etype, SyntaxError): | |
@@ -2056,26 +2054,21 b' class InteractiveShell(SingletonConfigurable):' | |||||
2056 |
|
2054 | |||
2057 | Parameters |
|
2055 | Parameters | |
2058 | ---------- |
|
2056 | ---------- | |
2059 |
|
2057 | text : string | ||
2060 | text : string |
|
2058 | A string of text to be completed on. It can be given as empty and | |
2061 | A string of text to be completed on. It can be given as empty and |
|
2059 | instead a line/position pair are given. In this case, the | |
2062 | instead a line/position pair are given. In this case, the |
|
2060 | completer itself will split the line like readline does. | |
2063 | completer itself will split the line like readline does. |
|
2061 | line : string, optional | |
2064 |
|
2062 | The complete line that text is part of. | ||
2065 |
|
|
2063 | cursor_pos : int, optional | |
2066 | The complete line that text is part of. |
|
2064 | The position of the cursor on the input line. | |
2067 |
|
||||
2068 | cursor_pos : int, optional |
|
|||
2069 | The position of the cursor on the input line. |
|
|||
2070 |
|
2065 | |||
2071 | Returns |
|
2066 | Returns | |
2072 | ------- |
|
2067 | ------- | |
2073 | text : string |
|
2068 | text : string | |
2074 | The actual text that was completed. |
|
2069 | The actual text that was completed. | |
2075 |
|
||||
2076 | matches : list |
|
2070 | matches : list | |
2077 | A sorted list with all possible completions. |
|
2071 | A sorted list with all possible completions. | |
2078 |
|
||||
2079 |
|
2072 | |||
2080 | Notes |
|
2073 | Notes | |
2081 | ----- |
|
2074 | ----- | |
@@ -2089,7 +2082,6 b' class InteractiveShell(SingletonConfigurable):' | |||||
2089 |
|
2082 | |||
2090 | Examples |
|
2083 | Examples | |
2091 | -------- |
|
2084 | -------- | |
2092 |
|
||||
2093 | In [1]: x = 'hello' |
|
2085 | In [1]: x = 'hello' | |
2094 |
|
2086 | |||
2095 | In [2]: _ip.complete('x.l') |
|
2087 | In [2]: _ip.complete('x.l') | |
@@ -2343,9 +2335,9 b' class InteractiveShell(SingletonConfigurable):' | |||||
2343 | Parameters |
|
2335 | Parameters | |
2344 | ---------- |
|
2336 | ---------- | |
2345 | cmd : str |
|
2337 | cmd : str | |
2346 | Command to execute (can not end in '&', as background processes are |
|
2338 | Command to execute (can not end in '&', as background processes are | |
2347 | not supported. Should not be a command that expects input |
|
2339 | not supported. Should not be a command that expects input | |
2348 | other than simple text. |
|
2340 | other than simple text. | |
2349 | """ |
|
2341 | """ | |
2350 | if cmd.rstrip().endswith('&'): |
|
2342 | if cmd.rstrip().endswith('&'): | |
2351 | # this is *far* from a rigorous test |
|
2343 | # this is *far* from a rigorous test | |
@@ -2367,7 +2359,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2367 | Parameters |
|
2359 | Parameters | |
2368 | ---------- |
|
2360 | ---------- | |
2369 | cmd : str |
|
2361 | cmd : str | |
2370 | Command to execute. |
|
2362 | Command to execute. | |
2371 | """ |
|
2363 | """ | |
2372 | cmd = self.var_expand(cmd, depth=1) |
|
2364 | cmd = self.var_expand(cmd, depth=1) | |
2373 | # warn if there is an IPython magic alternative. |
|
2365 | # warn if there is an IPython magic alternative. | |
@@ -2435,18 +2427,18 b' class InteractiveShell(SingletonConfigurable):' | |||||
2435 | Parameters |
|
2427 | Parameters | |
2436 | ---------- |
|
2428 | ---------- | |
2437 | cmd : str |
|
2429 | cmd : str | |
2438 | Command to execute (can not end in '&', as background processes are |
|
2430 | Command to execute (can not end in '&', as background processes are | |
2439 | not supported. |
|
2431 | not supported. | |
2440 | split : bool, optional |
|
2432 | split : bool, optional | |
2441 | If True, split the output into an IPython SList. Otherwise, an |
|
2433 | If True, split the output into an IPython SList. Otherwise, an | |
2442 | IPython LSString is returned. These are objects similar to normal |
|
2434 | IPython LSString is returned. These are objects similar to normal | |
2443 | lists and strings, with a few convenience attributes for easier |
|
2435 | lists and strings, with a few convenience attributes for easier | |
2444 | manipulation of line-based output. You can use '?' on them for |
|
2436 | manipulation of line-based output. You can use '?' on them for | |
2445 | details. |
|
2437 | details. | |
2446 | depth : int, optional |
|
2438 | depth : int, optional | |
2447 | How many frames above the caller are the local variables which should |
|
2439 | How many frames above the caller are the local variables which should | |
2448 | be expanded in the command string? The default (0) assumes that the |
|
2440 | be expanded in the command string? The default (0) assumes that the | |
2449 | expansion variables are in the stack frame calling this function. |
|
2441 | expansion variables are in the stack frame calling this function. | |
2450 | """ |
|
2442 | """ | |
2451 | if cmd.rstrip().endswith('&'): |
|
2443 | if cmd.rstrip().endswith('&'): | |
2452 | # this is *far* from a rigorous test |
|
2444 | # this is *far* from a rigorous test | |
@@ -2557,9 +2549,9 b' class InteractiveShell(SingletonConfigurable):' | |||||
2557 | Parameters |
|
2549 | Parameters | |
2558 | ---------- |
|
2550 | ---------- | |
2559 | expressions : dict |
|
2551 | expressions : dict | |
2560 | A dict with string keys and string values. The expression values |
|
2552 | A dict with string keys and string values. The expression values | |
2561 | should be valid Python expressions, each of which will be evaluated |
|
2553 | should be valid Python expressions, each of which will be evaluated | |
2562 | in the user namespace. |
|
2554 | in the user namespace. | |
2563 |
|
2555 | |||
2564 | Returns |
|
2556 | Returns | |
2565 | ------- |
|
2557 | ------- | |
@@ -2606,7 +2598,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2606 | ---------- |
|
2598 | ---------- | |
2607 | fname : string |
|
2599 | fname : string | |
2608 | The name of the file to be executed. |
|
2600 | The name of the file to be executed. | |
2609 | where : tuple |
|
2601 | *where : tuple | |
2610 | One or two namespaces, passed to execfile() as (globals,locals). |
|
2602 | One or two namespaces, passed to execfile() as (globals,locals). | |
2611 | If only one is given, it is passed as both. |
|
2603 | If only one is given, it is passed as both. | |
2612 | exit_ignore : bool (False) |
|
2604 | exit_ignore : bool (False) | |
@@ -2755,19 +2747,19 b' class InteractiveShell(SingletonConfigurable):' | |||||
2755 | Parameters |
|
2747 | Parameters | |
2756 | ---------- |
|
2748 | ---------- | |
2757 | raw_cell : str |
|
2749 | raw_cell : str | |
2758 | The code (including IPython code such as %magic functions) to run. |
|
2750 | The code (including IPython code such as %magic functions) to run. | |
2759 | store_history : bool |
|
2751 | store_history : bool | |
2760 | If True, the raw and translated cell will be stored in IPython's |
|
2752 | If True, the raw and translated cell will be stored in IPython's | |
2761 | history. For user code calling back into IPython's machinery, this |
|
2753 | history. For user code calling back into IPython's machinery, this | |
2762 | should be set to False. |
|
2754 | should be set to False. | |
2763 | silent : bool |
|
2755 | silent : bool | |
2764 | If True, avoid side-effects, such as implicit displayhooks and |
|
2756 | If True, avoid side-effects, such as implicit displayhooks and | |
2765 | and logging. silent=True forces store_history=False. |
|
2757 | and logging. silent=True forces store_history=False. | |
2766 | shell_futures : bool |
|
2758 | shell_futures : bool | |
2767 | If True, the code will share future statements with the interactive |
|
2759 | If True, the code will share future statements with the interactive | |
2768 | shell. It will both be affected by previous __future__ imports, and |
|
2760 | shell. It will both be affected by previous __future__ imports, and | |
2769 | any __future__ imports in the code will affect the shell. If False, |
|
2761 | any __future__ imports in the code will affect the shell. If False, | |
2770 | __future__ imports are not shared in either direction. |
|
2762 | __future__ imports are not shared in either direction. | |
2771 |
|
2763 | |||
2772 | Returns |
|
2764 | Returns | |
2773 | ------- |
|
2765 | ------- | |
@@ -2836,14 +2828,13 b' class InteractiveShell(SingletonConfigurable):' | |||||
2836 |
|
2828 | |||
2837 | Parameters |
|
2829 | Parameters | |
2838 | ---------- |
|
2830 | ---------- | |
2839 | raw_cell: str |
|
2831 | raw_cell : str | |
2840 | The code to be executed |
|
2832 | The code to be executed | |
2841 |
|
2833 | |||
2842 | Returns |
|
2834 | Returns | |
2843 | ------- |
|
2835 | ------- | |
2844 | result: bool |
|
2836 | result: bool | |
2845 | Whether the code needs to be run with a coroutine runner or not |
|
2837 | Whether the code needs to be run with a coroutine runner or not | |
2846 |
|
||||
2847 | .. versionadded:: 7.0 |
|
2838 | .. versionadded:: 7.0 | |
2848 | """ |
|
2839 | """ | |
2849 | if not self.autoawait: |
|
2840 | if not self.autoawait: | |
@@ -3075,8 +3066,8 b' class InteractiveShell(SingletonConfigurable):' | |||||
3075 | Parameters |
|
3066 | Parameters | |
3076 | ---------- |
|
3067 | ---------- | |
3077 | node : ast.Node |
|
3068 | node : ast.Node | |
3078 | The root node to be transformed. Typically called with the ast.Module |
|
3069 | The root node to be transformed. Typically called with the ast.Module | |
3079 | produced by parsing user input. |
|
3070 | produced by parsing user input. | |
3080 |
|
3071 | |||
3081 | Returns |
|
3072 | Returns | |
3082 | ------- |
|
3073 | ------- | |
@@ -3290,17 +3281,17 b' class InteractiveShell(SingletonConfigurable):' | |||||
3290 |
|
3281 | |||
3291 | Parameters |
|
3282 | Parameters | |
3292 | ---------- |
|
3283 | ---------- | |
3293 |
|
|
3284 | code : string | |
3294 | Python input code, which can be multiline. |
|
3285 | Python input code, which can be multiline. | |
3295 |
|
3286 | |||
3296 | Returns |
|
3287 | Returns | |
3297 | ------- |
|
3288 | ------- | |
3298 | status : str |
|
3289 | status : str | |
3299 | One of 'complete', 'incomplete', or 'invalid' if source is not a |
|
3290 | One of 'complete', 'incomplete', or 'invalid' if source is not a | |
3300 | prefix of valid code. |
|
3291 | prefix of valid code. | |
3301 | indent : str |
|
3292 | indent : str | |
3302 | When status is 'incomplete', this is some whitespace to insert on |
|
3293 | When status is 'incomplete', this is some whitespace to insert on | |
3303 | the next line of the prompt. |
|
3294 | the next line of the prompt. | |
3304 | """ |
|
3295 | """ | |
3305 | status, nspaces = self.input_transformer_manager.check_complete(code) |
|
3296 | status, nspaces = self.input_transformer_manager.check_complete(code) | |
3306 | return status, ' ' * (nspaces or 0) |
|
3297 | return status, ' ' * (nspaces or 0) | |
@@ -3327,13 +3318,13 b' class InteractiveShell(SingletonConfigurable):' | |||||
3327 | Parameters |
|
3318 | Parameters | |
3328 | ---------- |
|
3319 | ---------- | |
3329 | gui : optional, string |
|
3320 | gui : optional, string | |
3330 | If given, dictates the choice of matplotlib GUI backend to use |
|
3321 | If given, dictates the choice of matplotlib GUI backend to use | |
3331 | (should be one of IPython's supported backends, 'qt', 'osx', 'tk', |
|
3322 | (should be one of IPython's supported backends, 'qt', 'osx', 'tk', | |
3332 | 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by |
|
3323 | 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by | |
3333 | matplotlib (as dictated by the matplotlib build-time options plus the |
|
3324 | matplotlib (as dictated by the matplotlib build-time options plus the | |
3334 | user's matplotlibrc configuration file). Note that not all backends |
|
3325 | user's matplotlibrc configuration file). Note that not all backends | |
3335 | make sense in all contexts, for example a terminal ipython can't |
|
3326 | make sense in all contexts, for example a terminal ipython can't | |
3336 | display figures inline. |
|
3327 | display figures inline. | |
3337 | """ |
|
3328 | """ | |
3338 | from IPython.core import pylabtools as pt |
|
3329 | from IPython.core import pylabtools as pt | |
3339 | from matplotlib_inline.backend_inline import configure_inline_support |
|
3330 | from matplotlib_inline.backend_inline import configure_inline_support | |
@@ -3373,18 +3364,18 b' class InteractiveShell(SingletonConfigurable):' | |||||
3373 | Parameters |
|
3364 | Parameters | |
3374 | ---------- |
|
3365 | ---------- | |
3375 | gui : optional, string |
|
3366 | gui : optional, string | |
3376 | If given, dictates the choice of matplotlib GUI backend to use |
|
3367 | If given, dictates the choice of matplotlib GUI backend to use | |
3377 | (should be one of IPython's supported backends, 'qt', 'osx', 'tk', |
|
3368 | (should be one of IPython's supported backends, 'qt', 'osx', 'tk', | |
3378 | 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by |
|
3369 | 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by | |
3379 | matplotlib (as dictated by the matplotlib build-time options plus the |
|
3370 | matplotlib (as dictated by the matplotlib build-time options plus the | |
3380 | user's matplotlibrc configuration file). Note that not all backends |
|
3371 | user's matplotlibrc configuration file). Note that not all backends | |
3381 | make sense in all contexts, for example a terminal ipython can't |
|
3372 | make sense in all contexts, for example a terminal ipython can't | |
3382 | display figures inline. |
|
3373 | display figures inline. | |
3383 | import_all : optional, bool, default: True |
|
3374 | import_all : optional, bool, default: True | |
3384 | Whether to do `from numpy import *` and `from pylab import *` |
|
3375 | Whether to do `from numpy import *` and `from pylab import *` | |
3385 | in addition to module imports. |
|
3376 | in addition to module imports. | |
3386 | welcome_message : deprecated |
|
3377 | welcome_message : deprecated | |
3387 | This argument is ignored, no welcome message will be displayed. |
|
3378 | This argument is ignored, no welcome message will be displayed. | |
3388 | """ |
|
3379 | """ | |
3389 | from IPython.core.pylabtools import import_pylab |
|
3380 | from IPython.core.pylabtools import import_pylab | |
3390 |
|
3381 | |||
@@ -3491,7 +3482,6 b' class InteractiveShell(SingletonConfigurable):' | |||||
3491 |
|
3482 | |||
3492 | Notes |
|
3483 | Notes | |
3493 | ----- |
|
3484 | ----- | |
3494 |
|
||||
3495 | Slices can be described with two notations: |
|
3485 | Slices can be described with two notations: | |
3496 |
|
3486 | |||
3497 | * ``N:M`` -> standard python form, means including items N...(M-1). |
|
3487 | * ``N:M`` -> standard python form, means including items N...(M-1). | |
@@ -3517,26 +3507,25 b' class InteractiveShell(SingletonConfigurable):' | |||||
3517 | Parameters |
|
3507 | Parameters | |
3518 | ---------- |
|
3508 | ---------- | |
3519 | target : str |
|
3509 | target : str | |
3520 | A string specifying code to retrieve. This will be tried respectively |
|
3510 | A string specifying code to retrieve. This will be tried respectively | |
3521 | as: ranges of input history (see %history for syntax), url, |
|
3511 | as: ranges of input history (see %history for syntax), url, | |
3522 | corresponding .py file, filename, or an expression evaluating to a |
|
3512 | corresponding .py file, filename, or an expression evaluating to a | |
3523 | string or Macro in the user namespace. |
|
3513 | string or Macro in the user namespace. | |
3524 |
|
3514 | |||
3525 | If empty string is given, returns complete history of current |
|
3515 | If empty string is given, returns complete history of current | |
3526 | session, without the last line. |
|
3516 | session, without the last line. | |
3527 |
|
3517 | |||
3528 | raw : bool |
|
3518 | raw : bool | |
3529 | If true (default), retrieve raw history. Has no effect on the other |
|
3519 | If true (default), retrieve raw history. Has no effect on the other | |
3530 | retrieval mechanisms. |
|
3520 | retrieval mechanisms. | |
3531 |
|
3521 | |||
3532 | py_only : bool (default False) |
|
3522 | py_only : bool (default False) | |
3533 | Only try to fetch python code, do not try alternative methods to decode file |
|
3523 | Only try to fetch python code, do not try alternative methods to decode file | |
3534 | if unicode fails. |
|
3524 | if unicode fails. | |
3535 |
|
3525 | |||
3536 | Returns |
|
3526 | Returns | |
3537 | ------- |
|
3527 | ------- | |
3538 | A string of code. |
|
3528 | A string of code. | |
3539 |
|
||||
3540 | ValueError is raised if nothing is found, and TypeError if it evaluates |
|
3529 | ValueError is raised if nothing is found, and TypeError if it evaluates | |
3541 | to an object of another type. In each case, .args[0] is a printable |
|
3530 | to an object of another type. In each case, .args[0] is a printable | |
3542 | message. |
|
3531 | message. |
@@ -114,16 +114,13 b' def record_magic(dct, magic_kind, magic_name, func):' | |||||
114 | Parameters |
|
114 | Parameters | |
115 | ---------- |
|
115 | ---------- | |
116 | dct : dict |
|
116 | dct : dict | |
117 | A dictionary with 'line' and 'cell' subdicts. |
|
117 | A dictionary with 'line' and 'cell' subdicts. | |
118 |
|
||||
119 | magic_kind : str |
|
118 | magic_kind : str | |
120 | Kind of magic to be stored. |
|
119 | Kind of magic to be stored. | |
121 |
|
||||
122 | magic_name : str |
|
120 | magic_name : str | |
123 | Key to store the magic as. |
|
121 | Key to store the magic as. | |
124 |
|
||||
125 | func : function |
|
122 | func : function | |
126 | Callable object to store. |
|
123 | Callable object to store. | |
127 | """ |
|
124 | """ | |
128 | if magic_kind == 'line_cell': |
|
125 | if magic_kind == 'line_cell': | |
129 | dct['line'][magic_name] = dct['cell'][magic_name] = func |
|
126 | dct['line'][magic_name] = dct['cell'][magic_name] = func | |
@@ -372,7 +369,7 b' class MagicsManager(Configurable):' | |||||
372 | def register(self, *magic_objects): |
|
369 | def register(self, *magic_objects): | |
373 | """Register one or more instances of Magics. |
|
370 | """Register one or more instances of Magics. | |
374 |
|
371 | |||
375 |
Take one or more classes or instances of classes that subclass the main |
|
372 | Take one or more classes or instances of classes that subclass the main | |
376 | `core.Magic` class, and register them with IPython to use the magic |
|
373 | `core.Magic` class, and register them with IPython to use the magic | |
377 | functions they provide. The registration process will then ensure that |
|
374 | functions they provide. The registration process will then ensure that | |
378 | any methods that have decorated to provide line and/or cell magics will |
|
375 | any methods that have decorated to provide line and/or cell magics will | |
@@ -387,7 +384,7 b' class MagicsManager(Configurable):' | |||||
387 |
|
384 | |||
388 | Parameters |
|
385 | Parameters | |
389 | ---------- |
|
386 | ---------- | |
390 | magic_objects : one or more classes or instances |
|
387 | *magic_objects : one or more classes or instances | |
391 | """ |
|
388 | """ | |
392 | # Start by validating them to ensure they have all had their magic |
|
389 | # Start by validating them to ensure they have all had their magic | |
393 | # methods registered at the instance level |
|
390 | # methods registered at the instance level | |
@@ -410,7 +407,7 b' class MagicsManager(Configurable):' | |||||
410 |
|
407 | |||
411 | This will create an IPython magic (line, cell or both) from a |
|
408 | This will create an IPython magic (line, cell or both) from a | |
412 | standalone function. The functions should have the following |
|
409 | standalone function. The functions should have the following | |
413 |
signatures: |
|
410 | signatures: | |
414 |
|
411 | |||
415 | * For line magics: `def f(line)` |
|
412 | * For line magics: `def f(line)` | |
416 | * For cell magics: `def f(line, cell)` |
|
413 | * For cell magics: `def f(line, cell)` | |
@@ -422,14 +419,12 b' class MagicsManager(Configurable):' | |||||
422 | Parameters |
|
419 | Parameters | |
423 | ---------- |
|
420 | ---------- | |
424 | func : callable |
|
421 | func : callable | |
425 | Function to be registered as a magic. |
|
422 | Function to be registered as a magic. | |
426 |
|
||||
427 | magic_kind : str |
|
423 | magic_kind : str | |
428 | Kind of magic, one of 'line', 'cell' or 'line_cell' |
|
424 | Kind of magic, one of 'line', 'cell' or 'line_cell' | |
429 |
|
||||
430 | magic_name : optional str |
|
425 | magic_name : optional str | |
431 | If given, the name the magic will have in the IPython namespace. By |
|
426 | If given, the name the magic will have in the IPython namespace. By | |
432 | default, the name of the function itself is used. |
|
427 | default, the name of the function itself is used. | |
433 | """ |
|
428 | """ | |
434 |
|
429 | |||
435 | # Create the new method in the user_magics and register it in the |
|
430 | # Create the new method in the user_magics and register it in the | |
@@ -450,13 +445,11 b' class MagicsManager(Configurable):' | |||||
450 | Parameters |
|
445 | Parameters | |
451 | ---------- |
|
446 | ---------- | |
452 | alias_name : str |
|
447 | alias_name : str | |
453 | The name of the magic to be registered. |
|
448 | The name of the magic to be registered. | |
454 |
|
||||
455 | magic_name : str |
|
449 | magic_name : str | |
456 | The name of an existing magic. |
|
450 | The name of an existing magic. | |
457 |
|
||||
458 | magic_kind : str |
|
451 | magic_kind : str | |
459 | Kind of magic, one of 'line' or 'cell' |
|
452 | Kind of magic, one of 'line' or 'cell' | |
460 | """ |
|
453 | """ | |
461 |
|
454 | |||
462 | # `validate_type` is too permissive, as it allows 'line_cell' |
|
455 | # `validate_type` is too permissive, as it allows 'line_cell' | |
@@ -580,25 +573,20 b' class Magics(Configurable):' | |||||
580 |
|
573 | |||
581 | Parameters |
|
574 | Parameters | |
582 | ---------- |
|
575 | ---------- | |
583 |
|
||||
584 | arg_str : str |
|
576 | arg_str : str | |
585 | The arguments to parse. |
|
577 | The arguments to parse. | |
586 |
|
||||
587 | opt_str : str |
|
578 | opt_str : str | |
588 | The options specification. |
|
579 | The options specification. | |
589 |
|
||||
590 | mode : str, default 'string' |
|
580 | mode : str, default 'string' | |
591 | If given as 'list', the argument string is returned as a list (split |
|
581 | If given as 'list', the argument string is returned as a list (split | |
592 | on whitespace) instead of a string. |
|
582 | on whitespace) instead of a string. | |
593 |
|
||||
594 | list_all : bool, default False |
|
583 | list_all : bool, default False | |
595 | Put all option values in lists. Normally only options |
|
584 | Put all option values in lists. Normally only options | |
596 | appearing more than once are put in a list. |
|
585 | appearing more than once are put in a list. | |
597 |
|
||||
598 | posix : bool, default True |
|
586 | posix : bool, default True | |
599 | Whether to split the input line in POSIX mode or not, as per the |
|
587 | Whether to split the input line in POSIX mode or not, as per the | |
600 | conventions outlined in the :mod:`shlex` module from the standard |
|
588 | conventions outlined in the :mod:`shlex` module from the standard | |
601 | library. |
|
589 | library. | |
602 | """ |
|
590 | """ | |
603 |
|
591 | |||
604 | # inject default options at the beginning of the input line |
|
592 | # inject default options at the beginning of the input line |
@@ -46,7 +46,7 b' class MagicsDisplay(object):' | |||||
46 |
|
46 | |||
47 | def _jsonable(self): |
|
47 | def _jsonable(self): | |
48 | """turn magics dict into jsonable dict of the same structure |
|
48 | """turn magics dict into jsonable dict of the same structure | |
49 |
|
49 | |||
50 | replaces object instances with their class names as strings |
|
50 | replaces object instances with their class names as strings | |
51 | """ |
|
51 | """ | |
52 | magic_dict = {} |
|
52 | magic_dict = {} | |
@@ -124,7 +124,7 b' class BasicMagics(Magics):' | |||||
124 |
|
124 | |||
125 | In [6]: %whereami |
|
125 | In [6]: %whereami | |
126 | Out[6]: u'/home/testuser' |
|
126 | Out[6]: u'/home/testuser' | |
127 |
|
127 | |||
128 | In [7]: %alias_magic h history "-p -l 30" --line |
|
128 | In [7]: %alias_magic h history "-p -l 30" --line | |
129 | Created `%h` as an alias for `%history -l 30`. |
|
129 | Created `%h` as an alias for `%history -l 30`. | |
130 | """ |
|
130 | """ | |
@@ -368,7 +368,7 b' Currently the magic system has the following functions:""",' | |||||
368 |
|
368 | |||
369 | If called without arguments, acts as a toggle. |
|
369 | If called without arguments, acts as a toggle. | |
370 |
|
370 | |||
371 |
When in verbose mode the value --show (and --hide) |
|
371 | When in verbose mode the value --show (and --hide) | |
372 | will respectively show (or hide) frames with ``__tracebackhide__ = |
|
372 | will respectively show (or hide) frames with ``__tracebackhide__ = | |
373 | True`` value set. |
|
373 | True`` value set. | |
374 | """ |
|
374 | """ | |
@@ -618,12 +618,11 b' class AsyncMagics(BasicMagics):' | |||||
618 |
|
618 | |||
619 | If the passed parameter does not match any of the above and is a python |
|
619 | If the passed parameter does not match any of the above and is a python | |
620 | identifier, get said object from user namespace and set it as the |
|
620 | identifier, get said object from user namespace and set it as the | |
621 |
runner, and activate autoawait. |
|
621 | runner, and activate autoawait. | |
622 |
|
622 | |||
623 | If the object is a fully qualified object name, attempt to import it and |
|
623 | If the object is a fully qualified object name, attempt to import it and | |
624 | set it as the runner, and activate autoawait. |
|
624 | set it as the runner, and activate autoawait. | |
625 |
|
625 | |||
626 |
|
||||
627 | The exact behavior of autoawait is experimental and subject to change |
|
626 | The exact behavior of autoawait is experimental and subject to change | |
628 | across version of IPython and Python. |
|
627 | across version of IPython and Python. | |
629 | """ |
|
628 | """ |
@@ -1067,7 +1067,6 b' class ExecutionMagics(Magics):' | |||||
1067 |
|
1067 | |||
1068 | In [6]: %timeit -n1 time.sleep(2) |
|
1068 | In [6]: %timeit -n1 time.sleep(2) | |
1069 |
|
1069 | |||
1070 |
|
||||
1071 | The times reported by %timeit will be slightly higher than those |
|
1070 | The times reported by %timeit will be slightly higher than those | |
1072 | reported by the timeit.py script when variables are accessed. This is |
|
1071 | reported by the timeit.py script when variables are accessed. This is | |
1073 | due to the fact that %timeit executes the statement in the namespace |
|
1072 | due to the fact that %timeit executes the statement in the namespace | |
@@ -1201,7 +1200,7 b' class ExecutionMagics(Magics):' | |||||
1201 | The CPU and wall clock times are printed, and the value of the |
|
1200 | The CPU and wall clock times are printed, and the value of the | |
1202 | expression (if any) is returned. Note that under Win32, system time |
|
1201 | expression (if any) is returned. Note that under Win32, system time | |
1203 | is always reported as 0, since it can not be measured. |
|
1202 | is always reported as 0, since it can not be measured. | |
1204 |
|
1203 | |||
1205 | This function can be used both as a line and cell magic: |
|
1204 | This function can be used both as a line and cell magic: | |
1206 |
|
1205 | |||
1207 | - In line mode you can time a single-line statement (though multiple |
|
1206 | - In line mode you can time a single-line statement (though multiple | |
@@ -1238,7 +1237,6 b' class ExecutionMagics(Magics):' | |||||
1238 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
1237 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
1239 | Wall time: 0.00 |
|
1238 | Wall time: 0.00 | |
1240 |
|
1239 | |||
1241 |
|
||||
1242 | .. note:: |
|
1240 | .. note:: | |
1243 | The time needed by Python to compile the given expression will be |
|
1241 | The time needed by Python to compile the given expression will be | |
1244 | reported if it is more than 0.1s. |
|
1242 | reported if it is more than 0.1s. |
@@ -41,7 +41,7 b' class ExtensionMagics(Magics):' | |||||
41 | @line_magic |
|
41 | @line_magic | |
42 | def unload_ext(self, module_str): |
|
42 | def unload_ext(self, module_str): | |
43 | """Unload an IPython extension by its module name. |
|
43 | """Unload an IPython extension by its module name. | |
44 |
|
44 | |||
45 | Not all extensions can be unloaded, only those which define an |
|
45 | Not all extensions can be unloaded, only those which define an | |
46 | ``unload_ipython_extension`` function. |
|
46 | ``unload_ipython_extension`` function. | |
47 | """ |
|
47 | """ |
@@ -105,7 +105,7 b' class HistoryMagics(Magics):' | |||||
105 |
|
105 | |||
106 | By default, all input history from the current session is displayed. |
|
106 | By default, all input history from the current session is displayed. | |
107 | Ranges of history can be indicated using the syntax: |
|
107 | Ranges of history can be indicated using the syntax: | |
108 |
|
108 | |||
109 | ``4`` |
|
109 | ``4`` | |
110 | Line 4, current session |
|
110 | Line 4, current session | |
111 | ``4-6`` |
|
111 | ``4-6`` | |
@@ -117,7 +117,7 b' class HistoryMagics(Magics):' | |||||
117 | ``~8/1-~6/5`` |
|
117 | ``~8/1-~6/5`` | |
118 | From the first line of 8 sessions ago, to the fifth line of 6 |
|
118 | From the first line of 8 sessions ago, to the fifth line of 6 | |
119 | sessions ago. |
|
119 | sessions ago. | |
120 |
|
120 | |||
121 | Multiple ranges can be entered, separated by spaces |
|
121 | Multiple ranges can be entered, separated by spaces | |
122 |
|
122 | |||
123 | The same syntax is used by %macro, %save, %edit, %rerun |
|
123 | The same syntax is used by %macro, %save, %edit, %rerun |
@@ -173,7 +173,7 b' class NamespaceMagics(Magics):' | |||||
173 | 'builtin', 'user', 'user_global','internal', 'alias', where |
|
173 | 'builtin', 'user', 'user_global','internal', 'alias', where | |
174 | 'builtin' and 'user' are the search defaults. Note that you should |
|
174 | 'builtin' and 'user' are the search defaults. Note that you should | |
175 | not use quotes when specifying namespaces. |
|
175 | not use quotes when specifying namespaces. | |
176 |
|
176 | |||
177 | -l: List all available object types for object matching. This function |
|
177 | -l: List all available object types for object matching. This function | |
178 | can be used without arguments. |
|
178 | can be used without arguments. | |
179 |
|
179 | |||
@@ -203,9 +203,9 b' class NamespaceMagics(Magics):' | |||||
203 | Show objects beginning with a single _:: |
|
203 | Show objects beginning with a single _:: | |
204 |
|
204 | |||
205 | %psearch -a _* list objects beginning with a single underscore |
|
205 | %psearch -a _* list objects beginning with a single underscore | |
206 |
|
206 | |||
207 | List available objects:: |
|
207 | List available objects:: | |
208 |
|
208 | |||
209 | %psearch -l list all available object types |
|
209 | %psearch -l list all available object types | |
210 | """ |
|
210 | """ | |
211 | # default namespaces to be searched |
|
211 | # default namespaces to be searched | |
@@ -252,7 +252,6 b' class NamespaceMagics(Magics):' | |||||
252 |
|
252 | |||
253 | Examples |
|
253 | Examples | |
254 | -------- |
|
254 | -------- | |
255 |
|
||||
256 | Define two variables and list them with who_ls:: |
|
255 | Define two variables and list them with who_ls:: | |
257 |
|
256 | |||
258 | In [1]: alpha = 123 |
|
257 | In [1]: alpha = 123 | |
@@ -367,7 +366,6 b' class NamespaceMagics(Magics):' | |||||
367 |
|
366 | |||
368 | Examples |
|
367 | Examples | |
369 | -------- |
|
368 | -------- | |
370 |
|
||||
371 | Define two variables and list them with whos:: |
|
369 | Define two variables and list them with whos:: | |
372 |
|
370 | |||
373 | In [1]: alpha = 123 |
|
371 | In [1]: alpha = 123 | |
@@ -484,23 +482,21 b' class NamespaceMagics(Magics):' | |||||
484 |
|
482 | |||
485 | Parameters |
|
483 | Parameters | |
486 | ---------- |
|
484 | ---------- | |
487 | -f : force reset without asking for confirmation. |
|
485 | -f | |
488 |
|
486 | force reset without asking for confirmation. | ||
489 | -s : 'Soft' reset: Only clears your namespace, leaving history intact. |
|
487 | -s | |
|
488 | 'Soft' reset: Only clears your namespace, leaving history intact. | |||
490 | References to objects may be kept. By default (without this option), |
|
489 | References to objects may be kept. By default (without this option), | |
491 | we do a 'hard' reset, giving you a new session and removing all |
|
490 | we do a 'hard' reset, giving you a new session and removing all | |
492 | references to objects from the current session. |
|
491 | references to objects from the current session. | |
493 |
|
492 | --aggressive | ||
494 |
|
|
493 | Try to aggressively remove modules from sys.modules ; this | |
495 | may allow you to reimport Python modules that have been updated and |
|
494 | may allow you to reimport Python modules that have been updated and | |
496 | pick up changes, but can have unattended consequences. |
|
495 | pick up changes, but can have unattended consequences. | |
497 |
|
496 | |||
498 | in : reset input history |
|
497 | in : reset input history | |
499 |
|
||||
500 | out : reset output history |
|
498 | out : reset output history | |
501 |
|
||||
502 | dhist : reset directory history |
|
499 | dhist : reset directory history | |
503 |
|
||||
504 | array : reset only variables that are NumPy arrays |
|
500 | array : reset only variables that are NumPy arrays | |
505 |
|
501 | |||
506 | See Also |
|
502 | See Also | |
@@ -624,7 +620,6 b' class NamespaceMagics(Magics):' | |||||
624 |
|
620 | |||
625 | Examples |
|
621 | Examples | |
626 | -------- |
|
622 | -------- | |
627 |
|
||||
628 | We first fully reset the namespace so your output looks identical to |
|
623 | We first fully reset the namespace so your output looks identical to | |
629 | this example for pedagogical reasons; in practice you do not need a |
|
624 | this example for pedagogical reasons; in practice you do not need a | |
630 | full reset:: |
|
625 | full reset:: |
@@ -65,7 +65,7 b' class OSMagics(Magics):' | |||||
65 |
|
65 | |||
66 | def _isexec_POSIX(self, file): |
|
66 | def _isexec_POSIX(self, file): | |
67 | """ |
|
67 | """ | |
68 |
|
|
68 | Test for executable on a POSIX system | |
69 | """ |
|
69 | """ | |
70 | if os.access(file.path, os.X_OK): |
|
70 | if os.access(file.path, os.X_OK): | |
71 | # will fail on maxOS if access is not X_OK |
|
71 | # will fail on maxOS if access is not X_OK | |
@@ -76,13 +76,13 b' class OSMagics(Magics):' | |||||
76 |
|
76 | |||
77 | def _isexec_WIN(self, file): |
|
77 | def _isexec_WIN(self, file): | |
78 | """ |
|
78 | """ | |
79 |
|
|
79 | Test for executable file on non POSIX system | |
80 | """ |
|
80 | """ | |
81 | return file.is_file() and self.execre.match(file.name) is not None |
|
81 | return file.is_file() and self.execre.match(file.name) is not None | |
82 |
|
82 | |||
83 | def isexec(self, file): |
|
83 | def isexec(self, file): | |
84 | """ |
|
84 | """ | |
85 |
|
|
85 | Test for executable file on non POSIX system | |
86 | """ |
|
86 | """ | |
87 | if self.is_posix: |
|
87 | if self.is_posix: | |
88 | return self._isexec_POSIX(file) |
|
88 | return self._isexec_POSIX(file) | |
@@ -316,7 +316,6 b' class OSMagics(Magics):' | |||||
316 | ``cd <bookmark_name>`` is enough if there is no directory |
|
316 | ``cd <bookmark_name>`` is enough if there is no directory | |
317 | ``<bookmark_name>``, but a bookmark with the name exists. |
|
317 | ``<bookmark_name>``, but a bookmark with the name exists. | |
318 |
|
318 | |||
319 |
|
||||
320 | Options: |
|
319 | Options: | |
321 |
|
320 | |||
322 | -q Be quiet. Do not print the working directory after the |
|
321 | -q Be quiet. Do not print the working directory after the | |
@@ -329,7 +328,6 b' class OSMagics(Magics):' | |||||
329 | where ``!command`` runs is immediately discarded after executing |
|
328 | where ``!command`` runs is immediately discarded after executing | |
330 | 'command'. |
|
329 | 'command'. | |
331 |
|
330 | |||
332 |
|
||||
333 | Examples |
|
331 | Examples | |
334 | -------- |
|
332 | -------- | |
335 | :: |
|
333 | :: | |
@@ -834,7 +832,7 b' class OSMagics(Magics):' | |||||
834 | @cell_magic |
|
832 | @cell_magic | |
835 | def writefile(self, line, cell): |
|
833 | def writefile(self, line, cell): | |
836 | """Write the contents of the cell to a file. |
|
834 | """Write the contents of the cell to a file. | |
837 |
|
835 | |||
838 | The file will be overwritten unless the -a (--append) flag is specified. |
|
836 | The file will be overwritten unless the -a (--append) flag is specified. | |
839 | """ |
|
837 | """ | |
840 | args = magic_arguments.parse_argstring(self.writefile, line) |
|
838 | args = magic_arguments.parse_argstring(self.writefile, line) |
@@ -202,16 +202,16 b' class ScriptMagics(Magics):' | |||||
202 | @dec_safe_watcher |
|
202 | @dec_safe_watcher | |
203 | def shebang(self, line, cell): |
|
203 | def shebang(self, line, cell): | |
204 | """Run a cell via a shell command |
|
204 | """Run a cell via a shell command | |
205 |
|
205 | |||
206 | The `%%script` line is like the #! line of script, |
|
206 | The `%%script` line is like the #! line of script, | |
207 | specifying a program (bash, perl, ruby, etc.) with which to run. |
|
207 | specifying a program (bash, perl, ruby, etc.) with which to run. | |
208 |
|
208 | |||
209 | The rest of the cell is run by that program. |
|
209 | The rest of the cell is run by that program. | |
210 |
|
210 | |||
211 | Examples |
|
211 | Examples | |
212 | -------- |
|
212 | -------- | |
213 | :: |
|
213 | :: | |
214 |
|
214 | |||
215 | In [1]: %%script bash |
|
215 | In [1]: %%script bash | |
216 | ...: for i in 1 2 3; do |
|
216 | ...: for i in 1 2 3; do | |
217 | ...: echo $i |
|
217 | ...: echo $i |
@@ -302,7 +302,7 b' def find_file(obj) -> str:' | |||||
302 | Returns |
|
302 | Returns | |
303 | ------- |
|
303 | ------- | |
304 | fname : str |
|
304 | fname : str | |
305 | The absolute path to the file where the object was defined. |
|
305 | The absolute path to the file where the object was defined. | |
306 | """ |
|
306 | """ | |
307 | obj = _get_wrapped(obj) |
|
307 | obj = _get_wrapped(obj) | |
308 |
|
308 | |||
@@ -337,7 +337,7 b' def find_source_lines(obj):' | |||||
337 | Returns |
|
337 | Returns | |
338 | ------- |
|
338 | ------- | |
339 | lineno : int |
|
339 | lineno : int | |
340 | The line number where the object definition starts. |
|
340 | The line number where the object definition starts. | |
341 | """ |
|
341 | """ | |
342 | obj = _get_wrapped(obj) |
|
342 | obj = _get_wrapped(obj) | |
343 |
|
343 | |||
@@ -428,7 +428,6 b' class Inspector(Colorable):' | |||||
428 |
|
428 | |||
429 | Examples |
|
429 | Examples | |
430 | -------- |
|
430 | -------- | |
431 |
|
||||
432 | In [1]: class NoInit: |
|
431 | In [1]: class NoInit: | |
433 | ...: pass |
|
432 | ...: pass | |
434 |
|
433 | |||
@@ -575,18 +574,17 b' class Inspector(Colorable):' | |||||
575 | """Retrieve an info dict and format it. |
|
574 | """Retrieve an info dict and format it. | |
576 |
|
575 | |||
577 | Parameters |
|
576 | Parameters | |
578 | ========== |
|
577 | ---------- | |
579 |
|
578 | obj : any | ||
580 | obj: any |
|
|||
581 | Object to inspect and return info from |
|
579 | Object to inspect and return info from | |
582 | oname: str (default: ''): |
|
580 | oname: str (default: ''): | |
583 | Name of the variable pointing to `obj`. |
|
581 | Name of the variable pointing to `obj`. | |
584 | formatter: callable |
|
582 | formatter : callable | |
585 | info: |
|
583 | info: | |
586 | already computed information |
|
584 | already computed information | |
587 | detail_level: integer |
|
585 | detail_level : integer | |
588 | Granularity of detail level, if set to 1, give more information. |
|
586 | Granularity of detail level, if set to 1, give more information. | |
589 | omit_sections: container[str] |
|
587 | omit_sections : container[str] | |
590 | Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`) |
|
588 | Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`) | |
591 | """ |
|
589 | """ | |
592 |
|
590 | |||
@@ -716,21 +714,19 b' class Inspector(Colorable):' | |||||
716 | """Compute a dict with detailed information about an object. |
|
714 | """Compute a dict with detailed information about an object. | |
717 |
|
715 | |||
718 | Parameters |
|
716 | Parameters | |
719 | ========== |
|
717 | ---------- | |
720 |
|
718 | obj : any | ||
721 | obj: any |
|
|||
722 | An object to find information about |
|
719 | An object to find information about | |
723 |
oname: str (default: '') |
|
720 | oname : str (default: '') | |
724 | Name of the variable pointing to `obj`. |
|
721 | Name of the variable pointing to `obj`. | |
725 | info: (default: None) |
|
722 | info : (default: None) | |
726 | A struct (dict like with attr access) with some information fields |
|
723 | A struct (dict like with attr access) with some information fields | |
727 | which may have been precomputed already. |
|
724 | which may have been precomputed already. | |
728 | detail_level: int (default:0) |
|
725 | detail_level : int (default:0) | |
729 | If set to 1, more information is given. |
|
726 | If set to 1, more information is given. | |
730 |
|
727 | |||
731 | Returns |
|
728 | Returns | |
732 | ======= |
|
729 | ------- | |
733 |
|
||||
734 | An object info dict with known fields from `info_fields`. Keys are |
|
730 | An object info dict with known fields from `info_fields`. Keys are | |
735 | strings, values are string or None. |
|
731 | strings, values are string or None. | |
736 | """ |
|
732 | """ | |
@@ -962,7 +958,7 b' class Inspector(Colorable):' | |||||
962 |
|
958 | |||
963 | - show_all(False): show all names, including those starting with |
|
959 | - show_all(False): show all names, including those starting with | |
964 | underscores. |
|
960 | underscores. | |
965 |
|
961 | |||
966 | - list_types(False): list all available object types for object matching. |
|
962 | - list_types(False): list all available object types for object matching. | |
967 | """ |
|
963 | """ | |
968 | #print 'ps pattern:<%r>' % pattern # dbg |
|
964 | #print 'ps pattern:<%r>' % pattern # dbg |
@@ -46,7 +46,7 b' def display_page(strng, start=0, screen_lines=25):' | |||||
46 |
|
46 | |||
47 | def as_hook(page_func): |
|
47 | def as_hook(page_func): | |
48 | """Wrap a pager func to strip the `self` arg |
|
48 | """Wrap a pager func to strip the `self` arg | |
49 |
|
49 | |||
50 | so it can be called as a hook. |
|
50 | so it can be called as a hook. | |
51 | """ |
|
51 | """ | |
52 | return lambda self, *args, **kwargs: page_func(*args, **kwargs) |
|
52 | return lambda self, *args, **kwargs: page_func(*args, **kwargs) | |
@@ -127,7 +127,7 b' def _detect_screen_size(screen_lines_def):' | |||||
127 |
|
127 | |||
128 | def pager_page(strng, start=0, screen_lines=0, pager_cmd=None): |
|
128 | def pager_page(strng, start=0, screen_lines=0, pager_cmd=None): | |
129 | """Display a string, piping through a pager after a certain length. |
|
129 | """Display a string, piping through a pager after a certain length. | |
130 |
|
130 | |||
131 | strng can be a mime-bundle dict, supplying multiple representations, |
|
131 | strng can be a mime-bundle dict, supplying multiple representations, | |
132 | keyed by mime-type. |
|
132 | keyed by mime-type. | |
133 |
|
133 | |||
@@ -238,10 +238,10 b' def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):' | |||||
238 |
|
238 | |||
239 | def page(data, start=0, screen_lines=0, pager_cmd=None): |
|
239 | def page(data, start=0, screen_lines=0, pager_cmd=None): | |
240 | """Display content in a pager, piping through a pager after a certain length. |
|
240 | """Display content in a pager, piping through a pager after a certain length. | |
241 |
|
241 | |||
242 | data can be a mime-bundle dict, supplying multiple representations, |
|
242 | data can be a mime-bundle dict, supplying multiple representations, | |
243 | keyed by mime-type, or text. |
|
243 | keyed by mime-type, or text. | |
244 |
|
244 | |||
245 | Pager is dispatched via the `show_in_pager` IPython hook. |
|
245 | Pager is dispatched via the `show_in_pager` IPython hook. | |
246 | If no hook is registered, `pager_page` will be used. |
|
246 | If no hook is registered, `pager_page` will be used. | |
247 | """ |
|
247 | """ |
@@ -17,10 +17,9 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):' | |||||
17 | Parameters |
|
17 | Parameters | |
18 | ---------- |
|
18 | ---------- | |
19 | strng : str or mime-dict |
|
19 | strng : str or mime-dict | |
20 | Text to page, or a mime-type keyed dict of already formatted data. |
|
20 | Text to page, or a mime-type keyed dict of already formatted data. | |
21 |
|
||||
22 | start : int |
|
21 | start : int | |
23 | Starting line at which to place the display. |
|
22 | Starting line at which to place the display. | |
24 | """ |
|
23 | """ | |
25 |
|
24 | |||
26 | # Some routines may auto-compute start offsets incorrectly and pass a |
|
25 | # Some routines may auto-compute start offsets incorrectly and pass a | |
@@ -42,7 +41,7 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):' | |||||
42 |
|
41 | |||
43 | def install_payload_page(): |
|
42 | def install_payload_page(): | |
44 | """DEPRECATED, use show_in_pager hook |
|
43 | """DEPRECATED, use show_in_pager hook | |
45 |
|
44 | |||
46 | Install this version of page as IPython.core.page.page. |
|
45 | Install this version of page as IPython.core.page.page. | |
47 | """ |
|
46 | """ | |
48 | warnings.warn("""install_payload_page is deprecated. |
|
47 | warnings.warn("""install_payload_page is deprecated. |
@@ -185,8 +185,8 b' def mpl_runner(safe_execfile):' | |||||
185 | Parameters |
|
185 | Parameters | |
186 | ---------- |
|
186 | ---------- | |
187 | safe_execfile : function |
|
187 | safe_execfile : function | |
188 | This must be a function with the same interface as the |
|
188 | This must be a function with the same interface as the | |
189 | :meth:`safe_execfile` method of IPython. |
|
189 | :meth:`safe_execfile` method of IPython. | |
190 |
|
190 | |||
191 | Returns |
|
191 | Returns | |
192 | ------- |
|
192 | ------- | |
@@ -241,7 +241,7 b' def select_figure_formats(shell, formats, **kwargs):' | |||||
241 | """Select figure formats for the inline backend. |
|
241 | """Select figure formats for the inline backend. | |
242 |
|
242 | |||
243 | Parameters |
|
243 | Parameters | |
244 | ========== |
|
244 | ---------- | |
245 | shell : InteractiveShell |
|
245 | shell : InteractiveShell | |
246 | The main IPython instance. |
|
246 | The main IPython instance. | |
247 | formats : str or set |
|
247 | formats : str or set | |
@@ -408,7 +408,6 b' def configure_inline_support(shell, backend):' | |||||
408 | Parameters |
|
408 | Parameters | |
409 | ---------- |
|
409 | ---------- | |
410 | shell : InteractiveShell instance |
|
410 | shell : InteractiveShell instance | |
411 |
|
||||
412 | backend : matplotlib backend |
|
411 | backend : matplotlib backend | |
413 | """ |
|
412 | """ | |
414 | warnings.warn( |
|
413 | warnings.warn( |
@@ -556,7 +556,7 b' class ListTB(TBTools):' | |||||
556 | Parameters |
|
556 | Parameters | |
557 | ---------- |
|
557 | ---------- | |
558 | etype : exception type |
|
558 | etype : exception type | |
559 |
|
|
559 | value : exception value | |
560 | """ |
|
560 | """ | |
561 | return ListTB.structured_traceback(self, etype, value) |
|
561 | return ListTB.structured_traceback(self, etype, value) | |
562 |
|
562 |
@@ -75,7 +75,7 b' sys.meta_path.insert(0, ID)' | |||||
75 |
|
75 | |||
76 | def commit_api(api): |
|
76 | def commit_api(api): | |
77 | """Commit to a particular API, and trigger ImportErrors on subsequent |
|
77 | """Commit to a particular API, and trigger ImportErrors on subsequent | |
78 |
|
|
78 | dangerous imports""" | |
79 | modules = set(api_to_module.values()) |
|
79 | modules = set(api_to_module.values()) | |
80 |
|
80 | |||
81 | modules.remove(api_to_module[api]) |
|
81 | modules.remove(api_to_module[api]) | |
@@ -115,15 +115,15 b' def loaded_api():' | |||||
115 | def has_binding(api): |
|
115 | def has_binding(api): | |
116 | """Safely check for PyQt4/5, PySide or PySide2, without importing submodules |
|
116 | """Safely check for PyQt4/5, PySide or PySide2, without importing submodules | |
117 |
|
117 | |||
118 |
|
|
118 | Parameters | |
119 |
|
|
119 | ---------- | |
120 |
|
|
120 | api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault'] | |
121 |
|
|
121 | Which module to check for | |
122 |
|
122 | |||
123 |
|
|
123 | Returns | |
124 |
|
|
124 | ------- | |
125 |
|
|
125 | True if the relevant module appears to be importable | |
126 |
|
|
126 | """ | |
127 | module_name = api_to_module[api] |
|
127 | module_name = api_to_module[api] | |
128 | from importlib.util import find_spec |
|
128 | from importlib.util import find_spec | |
129 |
|
129 | |||
@@ -193,9 +193,8 b' def import_pyqt4(version=2):' | |||||
193 | Parameters |
|
193 | Parameters | |
194 | ---------- |
|
194 | ---------- | |
195 | version : 1, 2, or None |
|
195 | version : 1, 2, or None | |
196 | Which QString/QVariant API to use. Set to None to use the system |
|
196 | Which QString/QVariant API to use. Set to None to use the system | |
197 | default |
|
197 | default | |
198 |
|
||||
199 | ImportErrors raised within this function are non-recoverable |
|
198 | ImportErrors raised within this function are non-recoverable | |
200 | """ |
|
199 | """ | |
201 | # The new-style string API (version=2) automatically |
|
200 | # The new-style string API (version=2) automatically | |
@@ -319,13 +318,12 b' def load_qt(api_options):' | |||||
319 |
|
318 | |||
320 | Parameters |
|
319 | Parameters | |
321 | ---------- |
|
320 | ---------- | |
322 | api_options: List of strings |
|
321 | api_options : List of strings | |
323 | The order of APIs to try. Valid items are 'pyside', 'pyside2', |
|
322 | The order of APIs to try. Valid items are 'pyside', 'pyside2', | |
324 | 'pyqt', 'pyqt5', 'pyqtv1' and 'pyqtdefault' |
|
323 | 'pyqt', 'pyqt5', 'pyqtv1' and 'pyqtdefault' | |
325 |
|
324 | |||
326 | Returns |
|
325 | Returns | |
327 | ------- |
|
326 | ------- | |
328 |
|
||||
329 | A tuple of QtCore, QtGui, QtSvg, QT_API |
|
327 | A tuple of QtCore, QtGui, QtSvg, QT_API | |
330 | The first three are the Qt modules. The last is the |
|
328 | The first three are the Qt modules. The last is the | |
331 | string indicating which module was loaded. |
|
329 | string indicating which module was loaded. |
@@ -116,7 +116,7 b' class BackgroundJobManager(object):' | |||||
116 | The given expression is passed to eval(), along with the optional |
|
116 | The given expression is passed to eval(), along with the optional | |
117 | global/local dicts provided. If no dicts are given, they are |
|
117 | global/local dicts provided. If no dicts are given, they are | |
118 | extracted automatically from the caller's frame. |
|
118 | extracted automatically from the caller's frame. | |
119 |
|
119 | |||
120 | A Python statement is NOT a valid eval() expression. Basically, you |
|
120 | A Python statement is NOT a valid eval() expression. Basically, you | |
121 | can only use as an eval() argument something which can go on the right |
|
121 | can only use as an eval() argument something which can go on the right | |
122 | of an '=' sign and be assigned to a variable. |
|
122 | of an '=' sign and be assigned to a variable. |
@@ -239,7 +239,7 b' class Demo(object):' | |||||
239 | terminal16m |
|
239 | terminal16m | |
240 |
|
240 | |||
241 | - style('default'): a string of pygments style name to be used. |
|
241 | - style('default'): a string of pygments style name to be used. | |
242 |
|
|
242 | """ | |
243 | if hasattr(src, "read"): |
|
243 | if hasattr(src, "read"): | |
244 | # It seems to be a file or a file-like object |
|
244 | # It seems to be a file or a file-like object | |
245 | self.fname = "from a file-like object" |
|
245 | self.fname = "from a file-like object" |
@@ -517,20 +517,20 b' class FileLinks(FileLink):' | |||||
517 | fp_cleaner=None): |
|
517 | fp_cleaner=None): | |
518 | """ generate built-in formatter function |
|
518 | """ generate built-in formatter function | |
519 |
|
519 | |||
520 |
|
|
520 | this is used to define both the notebook and terminal built-in | |
521 |
|
|
521 | formatters as they only differ by some wrapper text for each entry | |
522 |
|
522 | |||
523 |
|
|
523 | dirname_output_format: string to use for formatting directory | |
524 |
|
|
524 | names, dirname will be substituted for a single "%s" which | |
525 |
|
|
525 | must appear in this string | |
526 |
|
|
526 | fname_output_format: string to use for formatting file names, | |
527 |
|
|
527 | if a single "%s" appears in the string, fname will be substituted | |
528 |
|
|
528 | if two "%s" appear in the string, the path to fname will be | |
529 |
|
|
529 | substituted for the first and fname will be substituted for the | |
530 |
|
|
530 | second | |
531 |
|
|
531 | fp_format: string to use for formatting filepaths, must contain | |
532 |
|
|
532 | exactly two "%s" and the dirname will be substituted for the first | |
533 |
|
|
533 | and fname will be substituted for the second | |
534 | """ |
|
534 | """ | |
535 | def f(dirname, fnames, included_suffixes=None): |
|
535 | def f(dirname, fnames, included_suffixes=None): | |
536 | result = [] |
|
536 | result = [] |
@@ -77,7 +77,6 b" def latex_to_png(s, encode=False, backend=None, wrap=False, color='Black'," | |||||
77 | format, e.g. '#AA20FA'. |
|
77 | format, e.g. '#AA20FA'. | |
78 | scale : float |
|
78 | scale : float | |
79 | Scale factor for the resulting PNG. |
|
79 | Scale factor for the resulting PNG. | |
80 |
|
||||
81 | None is returned when the backend cannot be used. |
|
80 | None is returned when the backend cannot be used. | |
82 |
|
81 | |||
83 | """ |
|
82 | """ |
@@ -49,7 +49,6 b' class EmbeddedMagics(Magics):' | |||||
49 | you may then kill it and the program will then continue to run without |
|
49 | you may then kill it and the program will then continue to run without | |
50 | the interactive shell interfering again. |
|
50 | the interactive shell interfering again. | |
51 |
|
51 | |||
52 |
|
||||
53 | Kill Instance Option: |
|
52 | Kill Instance Option: | |
54 |
|
53 | |||
55 | If for some reasons you need to kill the location where the instance |
|
54 | If for some reasons you need to kill the location where the instance | |
@@ -266,25 +265,21 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||||
266 |
|
265 | |||
267 | Parameters |
|
266 | Parameters | |
268 | ---------- |
|
267 | ---------- | |
269 |
|
||||
270 |
|
||||
271 | local_ns, module |
|
268 | local_ns, module | |
272 | Working local namespace (a dict) and module (a module or similar |
|
269 | Working local namespace (a dict) and module (a module or similar | |
273 | object). If given as None, they are automatically taken from the scope |
|
270 | object). If given as None, they are automatically taken from the scope | |
274 | where the shell was called, so that program variables become visible. |
|
271 | where the shell was called, so that program variables become visible. | |
275 |
|
||||
276 | stack_depth : int |
|
272 | stack_depth : int | |
277 | How many levels in the stack to go to looking for namespaces (when |
|
273 | How many levels in the stack to go to looking for namespaces (when | |
278 | local_ns or module is None). This allows an intermediate caller to |
|
274 | local_ns or module is None). This allows an intermediate caller to | |
279 | make sure that this function gets the namespace from the intended |
|
275 | make sure that this function gets the namespace from the intended | |
280 | level in the stack. By default (0) it will get its locals and globals |
|
276 | level in the stack. By default (0) it will get its locals and globals | |
281 | from the immediate caller. |
|
277 | from the immediate caller. | |
282 |
|
||||
283 | compile_flags |
|
278 | compile_flags | |
284 | A bit field identifying the __future__ features |
|
279 | A bit field identifying the __future__ features | |
285 | that are enabled, as passed to the builtin :func:`compile` function. |
|
280 | that are enabled, as passed to the builtin :func:`compile` function. | |
286 | If given as None, they are automatically taken from the scope where |
|
281 | If given as None, they are automatically taken from the scope where | |
287 | the shell was called. |
|
282 | the shell was called. | |
288 |
|
283 | |||
289 | """ |
|
284 | """ | |
290 |
|
285 |
@@ -113,9 +113,9 b' class TerminalMagics(Magics):' | |||||
113 |
|
113 | |||
114 | Shell escapes are not supported (yet). |
|
114 | Shell escapes are not supported (yet). | |
115 |
|
115 | |||
116 |
See |
|
116 | See Also | |
117 | -------- |
|
117 | -------- | |
118 | paste: automatically pull code from clipboard. |
|
118 | paste : automatically pull code from clipboard. | |
119 |
|
119 | |||
120 | Examples |
|
120 | Examples | |
121 | -------- |
|
121 | -------- | |
@@ -176,9 +176,9 b' class TerminalMagics(Magics):' | |||||
176 |
|
176 | |||
177 | IPython statements (magics, shell escapes) are not supported (yet). |
|
177 | IPython statements (magics, shell escapes) are not supported (yet). | |
178 |
|
178 | |||
179 |
See |
|
179 | See Also | |
180 | -------- |
|
180 | -------- | |
181 | cpaste: manually paste code into terminal until you mark its end. |
|
181 | cpaste : manually paste code into terminal until you mark its end. | |
182 | """ |
|
182 | """ | |
183 | opts, name = self.parse_options(parameter_s, 'rq', mode='string') |
|
183 | opts, name = self.parse_options(parameter_s, 'rq', mode='string') | |
184 | if 'r' in opts: |
|
184 | if 'r' in opts: |
@@ -22,12 +22,24 b' Need to be updated:' | |||||
22 |
|
22 | |||
23 | pr/* |
|
23 | pr/* | |
24 |
|
24 | |||
25 | IPython 8.0 is bringing a number of new features and improvements to both the |
|
25 | IPython 8.0 is bringing a large number of new features and improvements to both the | |
26 | user of the terminal and of the kernel via Jupyter. The removal of compatibility |
|
26 | user of the terminal and of the kernel via Jupyter. The removal of compatibility | |
27 | with older version of Python is also the opportunity to do a couple of |
|
27 | with older version of Python is also the opportunity to do a couple of | |
28 | performance improvement in particular with respect to startup time. |
|
28 | performance improvement in particular with respect to startup time. | |
29 |
|
29 | |||
30 | The main change in IPython 8.0 is the integration of the ``stack_data`` package; |
|
30 | This release contains 250+ Pull requests, in addition to many of the features | |
|
31 | and backports that have made it to the 7.x branch. | |||
|
32 | ||||
|
33 | We removed almost all features, arguments, functions, and modules that were | |||
|
34 | marked as deprecated between IPython 1.0 and 5.0 and before. As reminder 5.0 was | |||
|
35 | released in 2016, and 1.0 in 2013. Last release of the 5 branch was 5.10.0, in | |||
|
36 | may 2020. The few remaining deprecated features have better deprecation warnings | |||
|
37 | or errors. | |||
|
38 | ||||
|
39 | There are many change in IPython 8.0 will will try to describe subsequently, | |||
|
40 | ||||
|
41 | ||||
|
42 | The first on is the integration of the ``stack_data`` package; | |||
31 | which provide smarter information in traceback; in particular it will highlight |
|
43 | which provide smarter information in traceback; in particular it will highlight | |
32 | the AST node where an error occurs which can help to quickly narrow down errors. |
|
44 | the AST node where an error occurs which can help to quickly narrow down errors. | |
33 |
|
45 | |||
@@ -50,13 +62,34 b' IPython 8.0 is capable of telling you, where the index error occurs::' | |||||
50 | return x[0][i][0] |
|
62 | return x[0][i][0] | |
51 | ^ |
|
63 | ^ | |
52 |
|
64 | |||
|
65 | ||||
|
66 | Numfocus Small Developer Grant | |||
|
67 | ------------------------------ | |||
|
68 | ||||
53 | To prepare for Python 3.10 we have also started working on removing reliance and |
|
69 | To prepare for Python 3.10 we have also started working on removing reliance and | |
54 | any dependency that is not Python 3.10 compatible; that include migrating our |
|
70 | any dependency that is not Python 3.10 compatible; that include migrating our | |
55 |
test suite to |
|
71 | test suite to pytest, and starting to remove nose. This also mean that the | |
|
72 | ``iptest`` command is now gone, and all testing is via pytest. | |||
|
73 | ||||
|
74 | This was in bog part thanks the NumFOCUS Small Developer grant, we were able to | |||
|
75 | allocate 4000 to hire `Nikita Kniazev @Kojoley <https://github.com/Kojoley>`__ | |||
|
76 | who did a fantastic job at updating our code base, migrating to pytest, pushing | |||
|
77 | our coverage, and fixing a large number of bugs. I highly recommend contacting | |||
|
78 | them if you need help with C++ and Python projects | |||
56 |
|
79 | |||
57 | We are also removing support for Python 3.6 allowing internal code to use more |
|
80 | You can find all relevant issues and PRs with the SDG 2021 tag: | |
|
81 | ||||
|
82 | https://github.com/ipython/ipython/issues?q=label%3A%22Numfocus+SDG+2021%22+ | |||
|
83 | ||||
|
84 | Removing support for Older Python | |||
|
85 | --------------------------------- | |||
|
86 | ||||
|
87 | ||||
|
88 | We are also removing support for Python up to 3.7 allowing internal code to use more | |||
58 | efficient ``pathlib``, and make better use of type annotations. |
|
89 | efficient ``pathlib``, and make better use of type annotations. | |
59 |
|
90 | |||
|
91 | IMAGE : Pathlib, pathlib everywhere. | |||
|
92 | ||||
60 | The completer has also seen significant updates and make use of newer Jedi API |
|
93 | The completer has also seen significant updates and make use of newer Jedi API | |
61 | offering faster and more reliable tab completion. |
|
94 | offering faster and more reliable tab completion. | |
62 |
|
95 | |||
@@ -168,7 +201,154 b' Try ``%autoreload 3`` in an IPython session after running ``%load_ext autoreload' | |||||
168 | For more information please see unit test - |
|
201 | For more information please see unit test - | |
169 | extensions/tests/test_autoreload.py : 'test_autoload_newly_added_objects' |
|
202 | extensions/tests/test_autoreload.py : 'test_autoload_newly_added_objects' | |
170 |
|
203 | |||
171 | ======= |
|
204 | ||
|
205 | Miscelanious | |||
|
206 | ------------ | |||
|
207 | ||||
|
208 | Minimum supported | |||
|
209 | ||||
|
210 | ||||
|
211 | History Range Glob feature | |||
|
212 | ========================== | |||
|
213 | ||||
|
214 | Previously, when using ``%history``, users could specify either | |||
|
215 | a range of sessions and lines, for example: | |||
|
216 | ||||
|
217 | .. code-block:: python | |||
|
218 | ||||
|
219 | ~8/1-~6/5 # see history from the first line of 8 sessions ago, | |||
|
220 | # to the fifth line of 6 sessions ago.`` | |||
|
221 | ||||
|
222 | Or users could specify a glob pattern: | |||
|
223 | ||||
|
224 | .. code-block:: python | |||
|
225 | ||||
|
226 | -g <pattern> # glob ALL history for the specified pattern. | |||
|
227 | ||||
|
228 | However users could *not* specify both. | |||
|
229 | ||||
|
230 | If a user *did* specify both a range and a glob pattern, | |||
|
231 | then the glob pattern would be used (globbing *all* history) *and the range would be ignored*. | |||
|
232 | ||||
|
233 | --- | |||
|
234 | ||||
|
235 | With this enhancement, if a user specifies both a range and a glob pattern, then the glob pattern will be applied to the specified range of history. | |||
|
236 | ||||
|
237 | Don't start a multi line cell with sunken parenthesis | |||
|
238 | ----------------------------------------------------- | |||
|
239 | ||||
|
240 | From now on IPython will not ask for the next line of input when given a single | |||
|
241 | line with more closing than opening brackets. For example, this means that if | |||
|
242 | you (mis)type ']]' instead of '[]', a ``SyntaxError`` will show up, instead of | |||
|
243 | the ``...:`` prompt continuation. | |||
|
244 | ||||
|
245 | IPython shell for ipdb interact | |||
|
246 | ------------------------------- | |||
|
247 | ||||
|
248 | The ipdb ``interact`` starts an IPython shell instead of Python's built-in ``code.interact()``. | |||
|
249 | ||||
|
250 | Automatic Vi prompt stripping | |||
|
251 | ============================= | |||
|
252 | ||||
|
253 | When pasting code into IPython, it will strip the leading prompt characters if | |||
|
254 | there are any. For example, you can paste the following code into the console - | |||
|
255 | it will still work, even though each line is prefixed with prompts (`In`, | |||
|
256 | `Out`):: | |||
|
257 | ||||
|
258 | In [1]: 2 * 2 == 4 | |||
|
259 | Out[1]: True | |||
|
260 | ||||
|
261 | In [2]: print("This still works as pasted") | |||
|
262 | ||||
|
263 | ||||
|
264 | Previously, this was not the case for the Vi-mode prompts:: | |||
|
265 | ||||
|
266 | In [1]: [ins] In [13]: 2 * 2 == 4 | |||
|
267 | ...: Out[13]: True | |||
|
268 | ...: | |||
|
269 | File "<ipython-input-1-727bb88eaf33>", line 1 | |||
|
270 | [ins] In [13]: 2 * 2 == 4 | |||
|
271 | ^ | |||
|
272 | SyntaxError: invalid syntax | |||
|
273 | ||||
|
274 | This is now fixed, and Vi prompt prefixes - ``[ins]`` and ``[nav]`` - are | |||
|
275 | skipped just as the normal ``In`` would be. | |||
|
276 | ||||
|
277 | IPython shell can be started in the Vi mode using ``ipython | |||
|
278 | --TerminalInteractiveShell.editing_mode=vi`` | |||
|
279 | ||||
|
280 | Empty History Ranges | |||
|
281 | ==================== | |||
|
282 | ||||
|
283 | A number of magics that take history ranges can now be used with an empty | |||
|
284 | range. These magics are: | |||
|
285 | ||||
|
286 | * ``%save`` | |||
|
287 | * ``%load`` | |||
|
288 | * ``%pastebin`` | |||
|
289 | * ``%pycat`` | |||
|
290 | ||||
|
291 | Using them this way will make them take the history of the current session up | |||
|
292 | to the point of the magic call (such that the magic itself will not be | |||
|
293 | included). | |||
|
294 | ||||
|
295 | Therefore it is now possible to save the whole history to a file using simple | |||
|
296 | ``%save <filename>``, load and edit it using ``%load`` (makes for a nice usage | |||
|
297 | when followed with :kbd:`F2`), send it to dpaste.org using ``%pastebin``, or | |||
|
298 | view the whole thing syntax-highlighted with a single ``%pycat``. | |||
|
299 | ||||
|
300 | Traceback improvements | |||
|
301 | ====================== | |||
|
302 | ||||
|
303 | ||||
|
304 | UPDATE THIS IN INPUT. | |||
|
305 | ||||
|
306 | Previously, error tracebacks for errors happening in code cells were showing a hash, the one used for compiling the Python AST:: | |||
|
307 | ||||
|
308 | In [1]: def foo(): | |||
|
309 | ...: return 3 / 0 | |||
|
310 | ...: | |||
|
311 | ||||
|
312 | In [2]: foo() | |||
|
313 | --------------------------------------------------------------------------- | |||
|
314 | ZeroDivisionError Traceback (most recent call last) | |||
|
315 | <ipython-input-2-c19b6d9633cf> in <module> | |||
|
316 | ----> 1 foo() | |||
|
317 | ||||
|
318 | <ipython-input-1-1595a74c32d5> in foo() | |||
|
319 | 1 def foo(): | |||
|
320 | ----> 2 return 3 / 0 | |||
|
321 | 3 | |||
|
322 | ||||
|
323 | ZeroDivisionError: division by zero | |||
|
324 | ||||
|
325 | The error traceback is now correctly formatted, showing the cell number in which the error happened:: | |||
|
326 | ||||
|
327 | In [1]: def foo(): | |||
|
328 | ...: return 3 / 0 | |||
|
329 | ...: | |||
|
330 | ||||
|
331 | In [2]: foo() | |||
|
332 | --------------------------------------------------------------------------- | |||
|
333 | ZeroDivisionError Traceback (most recent call last) | |||
|
334 | In [2], in <module> | |||
|
335 | ----> 1 foo() | |||
|
336 | ||||
|
337 | In [1], in foo() | |||
|
338 | 1 def foo(): | |||
|
339 | ----> 2 return 3 / 0 | |||
|
340 | ||||
|
341 | ZeroDivisionError: division by zero | |||
|
342 | ||||
|
343 | Remove Deprecated Stuff | |||
|
344 | ======================= | |||
|
345 | ||||
|
346 | ||||
|
347 | We no longer need to add `extensions` to the PYTHONPATH because that is being | |||
|
348 | handled by `load_extension`. | |||
|
349 | ||||
|
350 | We are also removing Cythonmagic, sympyprinting and rmagic as they are now in | |||
|
351 | other packages and no longer need to be inside IPython. | |||
172 |
|
352 | |||
173 | .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT. |
|
353 | .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT. | |
174 |
|
354 |
@@ -101,7 +101,7 b' pygments.lexers =' | |||||
101 |
|
101 | |||
102 | [velin] |
|
102 | [velin] | |
103 | ignore_patterns = |
|
103 | ignore_patterns = | |
104 |
IPython/core/tests |
|
104 | IPython/core/tests | |
105 | IPython/testing |
|
105 | IPython/testing | |
106 |
|
106 | |||
107 | [tool.black] |
|
107 | [tool.black] |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now