##// END OF EJS Templates
reformat all of core
Matthias Bussonnier -
Show More
@@ -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,
@@ -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 source : string
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,24 +2054,21 b' class InteractiveShell(SingletonConfigurable):'
2056
2054
2057 Parameters
2055 Parameters
2058 ----------
2056 ----------
2059
2060 text : string
2057 text : string
2061 A string of text to be completed on. It can be given as empty and
2058 A string of text to be completed on. It can be given as empty and
2062 instead a line/position pair are given. In this case, the
2059 instead a line/position pair are given. In this case, the
2063 completer itself will split the line like readline does.
2060 completer itself will split the line like readline does.
2064 line : string, optional
2061 line : string, optional
2065 The complete line that text is part of.
2062 The complete line that text is part of.
2066 cursor_pos : int, optional
2063 cursor_pos : int, optional
2067 The position of the cursor on the input line.
2064 The position of the cursor on the input line.
2068
2065
2069 Returns
2066 Returns
2070 -------
2067 -------
2071 text : string
2068 text : string
2072 The actual text that was completed.
2069 The actual text that was completed.
2073
2074 matches : list
2070 matches : list
2075 A sorted list with all possible completions.
2071 A sorted list with all possible completions.
2076
2077
2072
2078 Notes
2073 Notes
2079 -----
2074 -----
@@ -2087,7 +2082,6 b' class InteractiveShell(SingletonConfigurable):'
2087
2082
2088 Examples
2083 Examples
2089 --------
2084 --------
2090
2091 In [1]: x = 'hello'
2085 In [1]: x = 'hello'
2092
2086
2093 In [2]: _ip.complete('x.l')
2087 In [2]: _ip.complete('x.l')
@@ -2341,9 +2335,9 b' class InteractiveShell(SingletonConfigurable):'
2341 Parameters
2335 Parameters
2342 ----------
2336 ----------
2343 cmd : str
2337 cmd : str
2344 Command to execute (can not end in '&', as background processes are
2338 Command to execute (can not end in '&', as background processes are
2345 not supported. Should not be a command that expects input
2339 not supported. Should not be a command that expects input
2346 other than simple text.
2340 other than simple text.
2347 """
2341 """
2348 if cmd.rstrip().endswith('&'):
2342 if cmd.rstrip().endswith('&'):
2349 # this is *far* from a rigorous test
2343 # this is *far* from a rigorous test
@@ -2365,7 +2359,7 b' class InteractiveShell(SingletonConfigurable):'
2365 Parameters
2359 Parameters
2366 ----------
2360 ----------
2367 cmd : str
2361 cmd : str
2368 Command to execute.
2362 Command to execute.
2369 """
2363 """
2370 cmd = self.var_expand(cmd, depth=1)
2364 cmd = self.var_expand(cmd, depth=1)
2371 # warn if there is an IPython magic alternative.
2365 # warn if there is an IPython magic alternative.
@@ -2433,18 +2427,18 b' class InteractiveShell(SingletonConfigurable):'
2433 Parameters
2427 Parameters
2434 ----------
2428 ----------
2435 cmd : str
2429 cmd : str
2436 Command to execute (can not end in '&', as background processes are
2430 Command to execute (can not end in '&', as background processes are
2437 not supported.
2431 not supported.
2438 split : bool, optional
2432 split : bool, optional
2439 If True, split the output into an IPython SList. Otherwise, an
2433 If True, split the output into an IPython SList. Otherwise, an
2440 IPython LSString is returned. These are objects similar to normal
2434 IPython LSString is returned. These are objects similar to normal
2441 lists and strings, with a few convenience attributes for easier
2435 lists and strings, with a few convenience attributes for easier
2442 manipulation of line-based output. You can use '?' on them for
2436 manipulation of line-based output. You can use '?' on them for
2443 details.
2437 details.
2444 depth : int, optional
2438 depth : int, optional
2445 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
2446 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
2447 expansion variables are in the stack frame calling this function.
2441 expansion variables are in the stack frame calling this function.
2448 """
2442 """
2449 if cmd.rstrip().endswith('&'):
2443 if cmd.rstrip().endswith('&'):
2450 # this is *far* from a rigorous test
2444 # this is *far* from a rigorous test
@@ -2555,9 +2549,9 b' class InteractiveShell(SingletonConfigurable):'
2555 Parameters
2549 Parameters
2556 ----------
2550 ----------
2557 expressions : dict
2551 expressions : dict
2558 A dict with string keys and string values. The expression values
2552 A dict with string keys and string values. The expression values
2559 should be valid Python expressions, each of which will be evaluated
2553 should be valid Python expressions, each of which will be evaluated
2560 in the user namespace.
2554 in the user namespace.
2561
2555
2562 Returns
2556 Returns
2563 -------
2557 -------
@@ -2753,19 +2747,19 b' class InteractiveShell(SingletonConfigurable):'
2753 Parameters
2747 Parameters
2754 ----------
2748 ----------
2755 raw_cell : str
2749 raw_cell : str
2756 The code (including IPython code such as %magic functions) to run.
2750 The code (including IPython code such as %magic functions) to run.
2757 store_history : bool
2751 store_history : bool
2758 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
2759 history. For user code calling back into IPython's machinery, this
2753 history. For user code calling back into IPython's machinery, this
2760 should be set to False.
2754 should be set to False.
2761 silent : bool
2755 silent : bool
2762 If True, avoid side-effects, such as implicit displayhooks and
2756 If True, avoid side-effects, such as implicit displayhooks and
2763 and logging. silent=True forces store_history=False.
2757 and logging. silent=True forces store_history=False.
2764 shell_futures : bool
2758 shell_futures : bool
2765 If True, the code will share future statements with the interactive
2759 If True, the code will share future statements with the interactive
2766 shell. It will both be affected by previous __future__ imports, and
2760 shell. It will both be affected by previous __future__ imports, and
2767 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,
2768 __future__ imports are not shared in either direction.
2762 __future__ imports are not shared in either direction.
2769
2763
2770 Returns
2764 Returns
2771 -------
2765 -------
@@ -2834,14 +2828,13 b' class InteractiveShell(SingletonConfigurable):'
2834
2828
2835 Parameters
2829 Parameters
2836 ----------
2830 ----------
2837 raw_cell: str
2831 raw_cell : str
2838 The code to be executed
2832 The code to be executed
2839
2833
2840 Returns
2834 Returns
2841 -------
2835 -------
2842 result: bool
2836 result: bool
2843 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
2844
2845 .. versionadded:: 7.0
2838 .. versionadded:: 7.0
2846 """
2839 """
2847 if not self.autoawait:
2840 if not self.autoawait:
@@ -3073,8 +3066,8 b' class InteractiveShell(SingletonConfigurable):'
3073 Parameters
3066 Parameters
3074 ----------
3067 ----------
3075 node : ast.Node
3068 node : ast.Node
3076 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
3077 produced by parsing user input.
3070 produced by parsing user input.
3078
3071
3079 Returns
3072 Returns
3080 -------
3073 -------
@@ -3288,17 +3281,17 b' class InteractiveShell(SingletonConfigurable):'
3288
3281
3289 Parameters
3282 Parameters
3290 ----------
3283 ----------
3291 source : string
3284 code : string
3292 Python input code, which can be multiline.
3285 Python input code, which can be multiline.
3293
3286
3294 Returns
3287 Returns
3295 -------
3288 -------
3296 status : str
3289 status : str
3297 One of 'complete', 'incomplete', or 'invalid' if source is not a
3290 One of 'complete', 'incomplete', or 'invalid' if source is not a
3298 prefix of valid code.
3291 prefix of valid code.
3299 indent : str
3292 indent : str
3300 When status is 'incomplete', this is some whitespace to insert on
3293 When status is 'incomplete', this is some whitespace to insert on
3301 the next line of the prompt.
3294 the next line of the prompt.
3302 """
3295 """
3303 status, nspaces = self.input_transformer_manager.check_complete(code)
3296 status, nspaces = self.input_transformer_manager.check_complete(code)
3304 return status, ' ' * (nspaces or 0)
3297 return status, ' ' * (nspaces or 0)
@@ -3325,13 +3318,13 b' class InteractiveShell(SingletonConfigurable):'
3325 Parameters
3318 Parameters
3326 ----------
3319 ----------
3327 gui : optional, string
3320 gui : optional, string
3328 If given, dictates the choice of matplotlib GUI backend to use
3321 If given, dictates the choice of matplotlib GUI backend to use
3329 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3322 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3330 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3323 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3331 matplotlib (as dictated by the matplotlib build-time options plus the
3324 matplotlib (as dictated by the matplotlib build-time options plus the
3332 user's matplotlibrc configuration file). Note that not all backends
3325 user's matplotlibrc configuration file). Note that not all backends
3333 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
3334 display figures inline.
3327 display figures inline.
3335 """
3328 """
3336 from IPython.core import pylabtools as pt
3329 from IPython.core import pylabtools as pt
3337 from matplotlib_inline.backend_inline import configure_inline_support
3330 from matplotlib_inline.backend_inline import configure_inline_support
@@ -3371,18 +3364,18 b' class InteractiveShell(SingletonConfigurable):'
3371 Parameters
3364 Parameters
3372 ----------
3365 ----------
3373 gui : optional, string
3366 gui : optional, string
3374 If given, dictates the choice of matplotlib GUI backend to use
3367 If given, dictates the choice of matplotlib GUI backend to use
3375 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3368 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3376 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3369 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3377 matplotlib (as dictated by the matplotlib build-time options plus the
3370 matplotlib (as dictated by the matplotlib build-time options plus the
3378 user's matplotlibrc configuration file). Note that not all backends
3371 user's matplotlibrc configuration file). Note that not all backends
3379 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
3380 display figures inline.
3373 display figures inline.
3381 import_all : optional, bool, default: True
3374 import_all : optional, bool, default: True
3382 Whether to do `from numpy import *` and `from pylab import *`
3375 Whether to do `from numpy import *` and `from pylab import *`
3383 in addition to module imports.
3376 in addition to module imports.
3384 welcome_message : deprecated
3377 welcome_message : deprecated
3385 This argument is ignored, no welcome message will be displayed.
3378 This argument is ignored, no welcome message will be displayed.
3386 """
3379 """
3387 from IPython.core.pylabtools import import_pylab
3380 from IPython.core.pylabtools import import_pylab
3388
3381
@@ -3489,7 +3482,6 b' class InteractiveShell(SingletonConfigurable):'
3489
3482
3490 Notes
3483 Notes
3491 -----
3484 -----
3492
3493 Slices can be described with two notations:
3485 Slices can be described with two notations:
3494
3486
3495 * ``N:M`` -> standard python form, means including items N...(M-1).
3487 * ``N:M`` -> standard python form, means including items N...(M-1).
@@ -3515,26 +3507,25 b' class InteractiveShell(SingletonConfigurable):'
3515 Parameters
3507 Parameters
3516 ----------
3508 ----------
3517 target : str
3509 target : str
3518 A string specifying code to retrieve. This will be tried respectively
3510 A string specifying code to retrieve. This will be tried respectively
3519 as: ranges of input history (see %history for syntax), url,
3511 as: ranges of input history (see %history for syntax), url,
3520 corresponding .py file, filename, or an expression evaluating to a
3512 corresponding .py file, filename, or an expression evaluating to a
3521 string or Macro in the user namespace.
3513 string or Macro in the user namespace.
3522
3514
3523 If empty string is given, returns complete history of current
3515 If empty string is given, returns complete history of current
3524 session, without the last line.
3516 session, without the last line.
3525
3517
3526 raw : bool
3518 raw : bool
3527 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
3528 retrieval mechanisms.
3520 retrieval mechanisms.
3529
3521
3530 py_only : bool (default False)
3522 py_only : bool (default False)
3531 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
3532 if unicode fails.
3524 if unicode fails.
3533
3525
3534 Returns
3526 Returns
3535 -------
3527 -------
3536 A string of code.
3528 A string of code.
3537
3538 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
3539 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
3540 message.
3531 message.
General Comments 0
You need to be logged in to leave comments. Login now