diff options
author | smosker <smosker@yandex-team.ru> | 2022-02-10 16:48:22 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:22 +0300 |
commit | 01fa2667d0e5e868b18424bc1906146e5ee340db (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /contrib/python/ipython/py2/IPython/core | |
parent | dd14d17a747a9c259858faf2fcc3ea6b92df4e15 (diff) | |
download | ydb-01fa2667d0e5e868b18424bc1906146e5ee340db.tar.gz |
Restoring authorship annotation for <smosker@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/ipython/py2/IPython/core')
24 files changed, 710 insertions, 710 deletions
diff --git a/contrib/python/ipython/py2/IPython/core/application.py b/contrib/python/ipython/py2/IPython/core/application.py index f6d002a06d..af28133945 100644 --- a/contrib/python/ipython/py2/IPython/core/application.py +++ b/contrib/python/ipython/py2/IPython/core/application.py @@ -44,14 +44,14 @@ else: "/etc/ipython", ] - -ENV_CONFIG_DIRS = [] -_env_config_dir = os.path.join(sys.prefix, 'etc', 'ipython') -if _env_config_dir not in SYSTEM_CONFIG_DIRS: - # only add ENV_CONFIG if sys.prefix is not already included - ENV_CONFIG_DIRS.append(_env_config_dir) - - + +ENV_CONFIG_DIRS = [] +_env_config_dir = os.path.join(sys.prefix, 'etc', 'ipython') +if _env_config_dir not in SYSTEM_CONFIG_DIRS: + # only add ENV_CONFIG if sys.prefix is not already included + ENV_CONFIG_DIRS.append(_env_config_dir) + + _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS') if _envvar in {None, ''}: IPYTHON_SUPPRESS_CONFIG_ERRORS = None @@ -411,7 +411,7 @@ class BaseIPythonApplication(Application): def init_config_files(self): """[optionally] copy default config files into profile dir.""" - self.config_file_paths.extend(ENV_CONFIG_DIRS) + self.config_file_paths.extend(ENV_CONFIG_DIRS) self.config_file_paths.extend(SYSTEM_CONFIG_DIRS) # copy config files path = self.builtin_profile_dir diff --git a/contrib/python/ipython/py2/IPython/core/compilerop.py b/contrib/python/ipython/py2/IPython/core/compilerop.py index 0e8f094e31..f529eb5224 100644 --- a/contrib/python/ipython/py2/IPython/core/compilerop.py +++ b/contrib/python/ipython/py2/IPython/core/compilerop.py @@ -56,7 +56,7 @@ def code_name(code, number=0): This now expects code to be unicode. """ - hash_digest = hashlib.sha1(code.encode("utf-8")).hexdigest() + hash_digest = hashlib.sha1(code.encode("utf-8")).hexdigest() # Include the number and 12 characters of the hash in the name. It's # pretty much impossible that in a single session we'll have collisions # even with truncated hashes, and the full one makes tracebacks too long diff --git a/contrib/python/ipython/py2/IPython/core/completer.py b/contrib/python/ipython/py2/IPython/core/completer.py index a8aaf1080b..b386945e54 100644 --- a/contrib/python/ipython/py2/IPython/core/completer.py +++ b/contrib/python/ipython/py2/IPython/core/completer.py @@ -25,7 +25,7 @@ import re import sys import unicodedata import string -import warnings +import warnings from traitlets.config.configurable import Configurable from IPython.core.error import TryNext @@ -47,9 +47,9 @@ if sys.platform == 'win32': else: PROTECTABLES = ' ()[]{}?=\\|;:\'#*"^&' -# Protect against returning an enormous number of completions which the frontend -# may have trouble processing. -MATCHES_LIMIT = 500 +# Protect against returning an enormous number of completions which the frontend +# may have trouble processing. +MATCHES_LIMIT = 500 def has_open_quotes(s): """Return whether a string has open quotes. @@ -243,11 +243,11 @@ class Completer(Configurable): """ ).tag(config=True) - backslash_combining_completions = Bool(True, - help="Enable unicode completions, e.g. \\alpha<tab> . " - "Includes completion of latex commands, unicode names, and expanding " - "unicode characters back to latex commands.").tag(config=True) - + backslash_combining_completions = Bool(True, + help="Enable unicode completions, e.g. \\alpha<tab> . " + "Includes completion of latex commands, unicode names, and expanding " + "unicode characters back to latex commands.").tag(config=True) + def __init__(self, namespace=None, global_namespace=None, **kwargs): """Create a new completer for the command line. @@ -549,13 +549,13 @@ class IPCompleter(Completer): """, ).tag(config=True) - @observe('limit_to__all__') - def _limit_to_all_changed(self, change): - warnings.warn('`IPython.core.IPCompleter.limit_to__all__` configuration ' - 'value has been deprecated since IPython 5.0, will be made to have ' - 'no effects and then removed in future version of IPython.', - UserWarning) - + @observe('limit_to__all__') + def _limit_to_all_changed(self, change): + warnings.warn('`IPython.core.IPCompleter.limit_to__all__` configuration ' + 'value has been deprecated since IPython 5.0, will be made to have ' + 'no effects and then removed in future version of IPython.', + UserWarning) + def __init__(self, shell=None, namespace=None, global_namespace=None, use_readline=True, config=None, **kwargs): """IPCompleter() -> completer @@ -1093,12 +1093,12 @@ class IPCompleter(Completer): return [cast_unicode_py2(r) for r in res if r.lower().startswith(text_low)] except TryNext: pass - except KeyboardInterrupt: - """ - If custom completer take too long, - let keyboard interrupt abort and return nothing. - """ - break + except KeyboardInterrupt: + """ + If custom completer take too long, + let keyboard interrupt abort and return nothing. + """ + break return None @@ -1137,21 +1137,21 @@ class IPCompleter(Completer): if cursor_pos is None: cursor_pos = len(line_buffer) if text is None else len(text) - if self.use_main_ns: - self.namespace = __main__.__dict__ + if self.use_main_ns: + self.namespace = __main__.__dict__ + + if PY3 and self.backslash_combining_completions: - if PY3 and self.backslash_combining_completions: - base_text = text if not line_buffer else line_buffer[:cursor_pos] latex_text, latex_matches = self.latex_matches(base_text) if latex_matches: - return latex_text, latex_matches + return latex_text, latex_matches name_text = '' name_matches = [] for meth in (self.unicode_name_matches, back_latex_name_matches, back_unicode_name_matches): name_text, name_matches = meth(base_text) if name_text: - return name_text, name_matches[:MATCHES_LIMIT] + return name_text, name_matches[:MATCHES_LIMIT] # if text is either None or an empty string, rely on the line buffer if not text: @@ -1192,6 +1192,6 @@ class IPCompleter(Completer): # different types of objects. The rlcomplete() method could then # simply collapse the dict into a list for readline, but we'd have # richer completion semantics in other evironments. - self.matches = sorted(set(self.matches), key=completions_sorting_key)[:MATCHES_LIMIT] + self.matches = sorted(set(self.matches), key=completions_sorting_key)[:MATCHES_LIMIT] return text, self.matches diff --git a/contrib/python/ipython/py2/IPython/core/completerlib.py b/contrib/python/ipython/py2/IPython/core/completerlib.py index a41f1c4af9..e736ca73d1 100644 --- a/contrib/python/ipython/py2/IPython/core/completerlib.py +++ b/contrib/python/ipython/py2/IPython/core/completerlib.py @@ -164,11 +164,11 @@ def get_root_modules(): ip.db['rootmodules_cache'] maps sys.path entries to list of modules. """ ip = get_ipython() - if ip is None: - # No global shell instance to store cached list of modules. - # Don't try to scan for modules every time. - return list(sys.builtin_module_names) - + if ip is None: + # No global shell instance to store cached list of modules. + # Don't try to scan for modules every time. + return list(sys.builtin_module_names) + rootmodules_cache = ip.db.get('rootmodules_cache', {}) rootmodules = list(sys.builtin_module_names) start_time = time() @@ -207,7 +207,7 @@ def is_importable(module, attr, only_modules): return not(attr[:2] == '__' and attr[-2:] == '__') def try_import(mod, only_modules=False): - mod = mod.rstrip('.') + mod = mod.rstrip('.') try: m = __import__(mod) except: diff --git a/contrib/python/ipython/py2/IPython/core/crashhandler.py b/contrib/python/ipython/py2/IPython/core/crashhandler.py index a6dededada..22bbd7ae81 100644 --- a/contrib/python/ipython/py2/IPython/core/crashhandler.py +++ b/contrib/python/ipython/py2/IPython/core/crashhandler.py @@ -54,16 +54,16 @@ with the subject '{app_name} Crash Report'. If you want to do it now, the following command will work (under Unix): mail -s '{app_name} Crash Report' {contact_email} < {crash_report_fname} -In your email, please also include information about: -- The operating system under which the crash happened: Linux, macOS, Windows, - other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2, - Windows 10 Pro), and whether it is 32-bit or 64-bit; -- How {app_name} was installed: using pip or conda, from GitHub, as part of - a Docker container, or other, providing more detail if possible; -- How to reproduce the crash: what exact sequence of instructions can one - input to get the same crash? Ideally, find a minimal yet complete sequence - of instructions that yields the crash. - +In your email, please also include information about: +- The operating system under which the crash happened: Linux, macOS, Windows, + other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2, + Windows 10 Pro), and whether it is 32-bit or 64-bit; +- How {app_name} was installed: using pip or conda, from GitHub, as part of + a Docker container, or other, providing more detail if possible; +- How to reproduce the crash: what exact sequence of instructions can one + input to get the same crash? Ideally, find a minimal yet complete sequence + of instructions that yields the crash. + To ensure accurate tracking of this issue, please file a report about it at: {bug_tracker} """ diff --git a/contrib/python/ipython/py2/IPython/core/debugger.py b/contrib/python/ipython/py2/IPython/core/debugger.py index a2f6200b31..f08cfb1a78 100644 --- a/contrib/python/ipython/py2/IPython/core/debugger.py +++ b/contrib/python/ipython/py2/IPython/core/debugger.py @@ -13,8 +13,8 @@ The code in this file is mainly lifted out of cmd.py in Python 2.2, with minor changes. Licensing should therefore be under the standard Python terms. For details on the PSF (Python Software Foundation) standard license, see: -https://docs.python.org/2/license.html -""" +https://docs.python.org/2/license.html +""" #***************************************************************************** # @@ -65,7 +65,7 @@ def BdbQuit_excepthook(et, ev, tb, excepthook=None): parameter. """ warnings.warn("`BdbQuit_excepthook` is deprecated since version 5.1", - DeprecationWarning, stacklevel=2) + DeprecationWarning, stacklevel=2) if et==bdb.BdbQuit: print('Exiting Debugger.') elif excepthook is not None: @@ -78,7 +78,7 @@ def BdbQuit_excepthook(et, ev, tb, excepthook=None): def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): warnings.warn( "`BdbQuit_IPython_excepthook` is deprecated since version 5.1", - DeprecationWarning, stacklevel=2) + DeprecationWarning, stacklevel=2) print('Exiting Debugger.') @@ -130,7 +130,7 @@ class Tracer(object): """ warnings.warn("`Tracer` is deprecated since version 5.1, directly use " "`IPython.core.debugger.Pdb.set_trace()`", - DeprecationWarning, stacklevel=2) + DeprecationWarning, stacklevel=2) ip = get_ipython() if ip is None: @@ -203,7 +203,7 @@ def _file_lines(fname): return out -class Pdb(OldPdb): +class Pdb(OldPdb): """Modified Pdb class, does not load readline. for a standalone version that uses prompt_toolkit, see @@ -228,14 +228,14 @@ class Pdb(OldPdb): self.shell = get_ipython() if self.shell is None: - save_main = sys.modules['__main__'] + save_main = sys.modules['__main__'] # No IPython instance running, we must create one from IPython.terminal.interactiveshell import \ TerminalInteractiveShell self.shell = TerminalInteractiveShell.instance() - # needed by any code which calls __import__("__main__") after - # the debugger was entered. See also #9941. - sys.modules['__main__'] = save_main + # needed by any code which calls __import__("__main__") after + # the debugger was entered. See also #9941. + sys.modules['__main__'] = save_main if color_scheme is not None: warnings.warn( @@ -485,8 +485,8 @@ class Pdb(OldPdb): pass def do_list(self, arg): - """Print lines of code from the current stack frame - """ + """Print lines of code from the current stack frame + """ self.lastcmd = 'list' last = None if arg: @@ -530,10 +530,10 @@ class Pdb(OldPdb): return inspect.getblock(lines[lineno:]), lineno+1 def do_longlist(self, arg): - """Print lines of code from the current stack frame. - - Shows more lines than 'list' does. - """ + """Print lines of code from the current stack frame. + + Shows more lines than 'list' does. + """ self.lastcmd = 'longlist' try: lines, lineno = self.getsourcelines(self.curframe) @@ -607,12 +607,12 @@ class Pdb(OldPdb): self.print_stack_trace() do_w = do_where - - -def set_trace(frame=None): - """ - Start debugging from `frame`. - - If frame is not specified, debugging starts from caller's frame. - """ - Pdb().set_trace(frame or sys._getframe().f_back) + + +def set_trace(frame=None): + """ + Start debugging from `frame`. + + If frame is not specified, debugging starts from caller's frame. + """ + Pdb().set_trace(frame or sys._getframe().f_back) diff --git a/contrib/python/ipython/py2/IPython/core/display.py b/contrib/python/ipython/py2/IPython/core/display.py index c696f6c831..5c82a57b31 100644 --- a/contrib/python/ipython/py2/IPython/core/display.py +++ b/contrib/python/ipython/py2/IPython/core/display.py @@ -11,7 +11,7 @@ try: except ImportError: from base64 import encodestring as base64_encode -from binascii import b2a_hex, hexlify +from binascii import b2a_hex, hexlify import json import mimetypes import os @@ -26,9 +26,9 @@ from IPython.testing.skipdoctest import skip_doctest __all__ = ['display', 'display_pretty', 'display_html', 'display_markdown', 'display_svg', 'display_png', 'display_jpeg', 'display_latex', 'display_json', 'display_javascript', 'display_pdf', 'DisplayObject', 'TextDisplayObject', -'Pretty', 'HTML', 'Markdown', 'Math', 'Latex', 'SVG', 'ProgressBar', 'JSON', 'Javascript', +'Pretty', 'HTML', 'Markdown', 'Math', 'Latex', 'SVG', 'ProgressBar', 'JSON', 'Javascript', 'Image', 'clear_output', 'set_matplotlib_formats', 'set_matplotlib_close', -'publish_display_data', 'update_display', 'DisplayHandle'] +'publish_display_data', 'update_display', 'DisplayHandle'] #----------------------------------------------------------------------------- # utility functions @@ -79,8 +79,8 @@ def _display_mimetype(mimetype, objs, raw=False, metadata=None): #----------------------------------------------------------------------------- # Main functions #----------------------------------------------------------------------------- -# use * to indicate transient is keyword-only -def publish_display_data(data, metadata=None, source=None, **kwargs): +# use * to indicate transient is keyword-only +def publish_display_data(data, metadata=None, source=None, **kwargs): """Publish data and metadata to all frontends. See the ``display_data`` message in the messaging documentation for @@ -115,38 +115,38 @@ def publish_display_data(data, metadata=None, source=None, **kwargs): to specify metadata about particular representations. source : str, deprecated Unused. - transient : dict, keyword-only - A dictionary of transient data, such as display_id. + transient : dict, keyword-only + A dictionary of transient data, such as display_id. """ from IPython.core.interactiveshell import InteractiveShell - - display_pub = InteractiveShell.instance().display_pub - - # only pass transient if supplied, - # to avoid errors with older ipykernel. - # TODO: We could check for ipykernel version and provide a detailed upgrade message. - - display_pub.publish( + + display_pub = InteractiveShell.instance().display_pub + + # only pass transient if supplied, + # to avoid errors with older ipykernel. + # TODO: We could check for ipykernel version and provide a detailed upgrade message. + + display_pub.publish( data=data, metadata=metadata, - **kwargs + **kwargs ) - -def _new_id(): - """Generate a new random text id with urandom""" - return b2a_hex(os.urandom(16)).decode('ascii') - - + +def _new_id(): + """Generate a new random text id with urandom""" + return b2a_hex(os.urandom(16)).decode('ascii') + + def display(*objs, **kwargs): """Display a Python object in all frontends. By default all representations will be computed and sent to the frontends. Frontends can decide which representation is used and how. - In terminal IPython this will be similar to using :func:`print`, for use in richer - frontends see Jupyter notebook examples with rich display logic. - + In terminal IPython this will be similar to using :func:`print`, for use in richer + frontends see Jupyter notebook examples with rich display logic. + Parameters ---------- objs : tuple of objects @@ -154,11 +154,11 @@ def display(*objs, **kwargs): raw : bool, optional Are the objects to be displayed already mimetype-keyed dicts of raw display data, or Python objects that need to be formatted before display? [default: False] - include : list, tuple or set, optional + include : list, tuple or set, optional A list of format type strings (MIME types) to include in the format data dict. If this is set *only* the format types included in this list will be computed. - exclude : list, tuple or set, optional + exclude : list, tuple or set, optional A list of format type strings (MIME types) to exclude in the format data dict. If this is set all format types will be computed, except for those included in this argument. @@ -166,147 +166,147 @@ def display(*objs, **kwargs): A dictionary of metadata to associate with the output. mime-type keys in this dictionary will be associated with the individual representation formats, if they exist. - transient : dict, optional - A dictionary of transient data to associate with the output. - Data in this dict should not be persisted to files (e.g. notebooks). - display_id : str, bool optional - Set an id for the display. - This id can be used for updating this display area later via update_display. - If given as `True`, generate a new `display_id` - kwargs: additional keyword-args, optional - Additional keyword-arguments are passed through to the display publisher. - - Returns - ------- - - handle: DisplayHandle - Returns a handle on updatable displays for use with :func:`update_display`, - if `display_id` is given. Returns :any:`None` if no `display_id` is given - (default). - - Examples - -------- - - >>> class Json(object): - ... def __init__(self, json): - ... self.json = json - ... def _repr_pretty_(self, pp, cycle): - ... import json - ... pp.text(json.dumps(self.json, indent=2)) - ... def __repr__(self): - ... return str(self.json) - ... - - >>> d = Json({1:2, 3: {4:5}}) - - >>> print(d) - {1: 2, 3: {4: 5}} - - >>> display(d) - { - "1": 2, - "3": { - "4": 5 - } - } - - >>> def int_formatter(integer, pp, cycle): - ... pp.text('I'*integer) - - >>> plain = get_ipython().display_formatter.formatters['text/plain'] - >>> plain.for_type(int, int_formatter) - <function _repr_pprint at 0x...> - >>> display(7-5) - II - - >>> del plain.type_printers[int] - >>> display(7-5) - 2 - - See Also - -------- - - :func:`update_display` - - Notes - ----- - - In Python, objects can declare their textual representation using the - `__repr__` method. IPython expands on this idea and allows objects to declare - other, rich representations including: - - - HTML - - JSON - - PNG - - JPEG - - SVG - - LaTeX - - A single object can declare some or all of these representations; all are - handled by IPython's display system. - - The main idea of the first approach is that you have to implement special - display methods when you define your class, one for each representation you - want to use. Here is a list of the names of the special methods and the - values they must return: - - - `_repr_html_`: return raw HTML as a string - - `_repr_json_`: return a JSONable dict - - `_repr_jpeg_`: return raw JPEG data - - `_repr_png_`: return raw PNG data - - `_repr_svg_`: return raw SVG data as a string - - `_repr_latex_`: return LaTeX commands in a string surrounded by "$". - - `_repr_mimebundle_`: return a full mimebundle containing the mapping - from all mimetypes to data - - When you are directly writing your own classes, you can adapt them for - display in IPython by following the above approach. But in practice, you - often need to work with existing classes that you can't easily modify. - - You can refer to the documentation on IPython display formatters in order to - register custom formatters for already existing types. - - .. versionadded:: 5.4 display available without import - .. versionadded:: 6.1 display available without import - - Since IPython 5.4 and 6.1 :func:`display` is automatically made available to - the user without import. If you are using display in a document that might - be used in a pure python context or with older version of IPython, use the - following import at the top of your file:: - - from IPython.display import display - + transient : dict, optional + A dictionary of transient data to associate with the output. + Data in this dict should not be persisted to files (e.g. notebooks). + display_id : str, bool optional + Set an id for the display. + This id can be used for updating this display area later via update_display. + If given as `True`, generate a new `display_id` + kwargs: additional keyword-args, optional + Additional keyword-arguments are passed through to the display publisher. + + Returns + ------- + + handle: DisplayHandle + Returns a handle on updatable displays for use with :func:`update_display`, + if `display_id` is given. Returns :any:`None` if no `display_id` is given + (default). + + Examples + -------- + + >>> class Json(object): + ... def __init__(self, json): + ... self.json = json + ... def _repr_pretty_(self, pp, cycle): + ... import json + ... pp.text(json.dumps(self.json, indent=2)) + ... def __repr__(self): + ... return str(self.json) + ... + + >>> d = Json({1:2, 3: {4:5}}) + + >>> print(d) + {1: 2, 3: {4: 5}} + + >>> display(d) + { + "1": 2, + "3": { + "4": 5 + } + } + + >>> def int_formatter(integer, pp, cycle): + ... pp.text('I'*integer) + + >>> plain = get_ipython().display_formatter.formatters['text/plain'] + >>> plain.for_type(int, int_formatter) + <function _repr_pprint at 0x...> + >>> display(7-5) + II + + >>> del plain.type_printers[int] + >>> display(7-5) + 2 + + See Also + -------- + + :func:`update_display` + + Notes + ----- + + In Python, objects can declare their textual representation using the + `__repr__` method. IPython expands on this idea and allows objects to declare + other, rich representations including: + + - HTML + - JSON + - PNG + - JPEG + - SVG + - LaTeX + + A single object can declare some or all of these representations; all are + handled by IPython's display system. + + The main idea of the first approach is that you have to implement special + display methods when you define your class, one for each representation you + want to use. Here is a list of the names of the special methods and the + values they must return: + + - `_repr_html_`: return raw HTML as a string + - `_repr_json_`: return a JSONable dict + - `_repr_jpeg_`: return raw JPEG data + - `_repr_png_`: return raw PNG data + - `_repr_svg_`: return raw SVG data as a string + - `_repr_latex_`: return LaTeX commands in a string surrounded by "$". + - `_repr_mimebundle_`: return a full mimebundle containing the mapping + from all mimetypes to data + + When you are directly writing your own classes, you can adapt them for + display in IPython by following the above approach. But in practice, you + often need to work with existing classes that you can't easily modify. + + You can refer to the documentation on IPython display formatters in order to + register custom formatters for already existing types. + + .. versionadded:: 5.4 display available without import + .. versionadded:: 6.1 display available without import + + Since IPython 5.4 and 6.1 :func:`display` is automatically made available to + the user without import. If you are using display in a document that might + be used in a pure python context or with older version of IPython, use the + following import at the top of your file:: + + from IPython.display import display + """ from IPython.core.interactiveshell import InteractiveShell - - if not InteractiveShell.initialized(): - # Directly print objects. - print(*objs) - return - - raw = kwargs.pop('raw', False) - include = kwargs.pop('include', None) - exclude = kwargs.pop('exclude', None) - metadata = kwargs.pop('metadata', None) - transient = kwargs.pop('transient', None) - display_id = kwargs.pop('display_id', None) - if transient is None: - transient = {} - if display_id: - if display_id is True: - display_id = _new_id() - transient['display_id'] = display_id - if kwargs.get('update') and 'display_id' not in transient: - raise TypeError('display_id required for update_display') - if transient: - kwargs['transient'] = transient + + if not InteractiveShell.initialized(): + # Directly print objects. + print(*objs) + return + + raw = kwargs.pop('raw', False) + include = kwargs.pop('include', None) + exclude = kwargs.pop('exclude', None) + metadata = kwargs.pop('metadata', None) + transient = kwargs.pop('transient', None) + display_id = kwargs.pop('display_id', None) + if transient is None: + transient = {} + if display_id: + if display_id is True: + display_id = _new_id() + transient['display_id'] = display_id + if kwargs.get('update') and 'display_id' not in transient: + raise TypeError('display_id required for update_display') + if transient: + kwargs['transient'] = transient if not raw: format = InteractiveShell.instance().display_formatter.format for obj in objs: if raw: - publish_display_data(data=obj, metadata=metadata, **kwargs) + publish_display_data(data=obj, metadata=metadata, **kwargs) else: format_dict, md_dict = format(obj, include=include, exclude=exclude) if not format_dict: @@ -315,86 +315,86 @@ def display(*objs, **kwargs): if metadata: # kwarg-specified metadata gets precedence _merge(md_dict, metadata) - publish_display_data(data=format_dict, metadata=md_dict, **kwargs) - if display_id: - return DisplayHandle(display_id) - - -# use * for keyword-only display_id arg -def update_display(obj, **kwargs): - """Update an existing display by id - - Parameters - ---------- - - obj: - The object with which to update the display - display_id: keyword-only - The id of the display to update - - See Also - -------- - - :func:`display` - """ - sentinel = object() - display_id = kwargs.pop('display_id', sentinel) - if display_id is sentinel: - raise TypeError("update_display() missing 1 required keyword-only argument: 'display_id'") - kwargs['update'] = True - display(obj, display_id=display_id, **kwargs) - - -class DisplayHandle(object): - """A handle on an updatable display - - Call `.update(obj)` to display a new object. - - Call `.display(obj`) to add a new instance of this display, - and update existing instances. - - See Also - -------- - - :func:`display`, :func:`update_display` - - """ - - def __init__(self, display_id=None): - if display_id is None: - display_id = _new_id() - self.display_id = display_id - - def __repr__(self): - return "<%s display_id=%s>" % (self.__class__.__name__, self.display_id) - - def display(self, obj, **kwargs): - """Make a new display with my id, updating existing instances. - - Parameters - ---------- - - obj: - object to display - **kwargs: - additional keyword arguments passed to display - """ - display(obj, display_id=self.display_id, **kwargs) - - def update(self, obj, **kwargs): - """Update existing displays with my id - - Parameters - ---------- - - obj: - object to display - **kwargs: - additional keyword arguments passed to update_display - """ - update_display(obj, display_id=self.display_id, **kwargs) - - + publish_display_data(data=format_dict, metadata=md_dict, **kwargs) + if display_id: + return DisplayHandle(display_id) + + +# use * for keyword-only display_id arg +def update_display(obj, **kwargs): + """Update an existing display by id + + Parameters + ---------- + + obj: + The object with which to update the display + display_id: keyword-only + The id of the display to update + + See Also + -------- + + :func:`display` + """ + sentinel = object() + display_id = kwargs.pop('display_id', sentinel) + if display_id is sentinel: + raise TypeError("update_display() missing 1 required keyword-only argument: 'display_id'") + kwargs['update'] = True + display(obj, display_id=display_id, **kwargs) + + +class DisplayHandle(object): + """A handle on an updatable display + + Call `.update(obj)` to display a new object. + + Call `.display(obj`) to add a new instance of this display, + and update existing instances. + + See Also + -------- + + :func:`display`, :func:`update_display` + + """ + + def __init__(self, display_id=None): + if display_id is None: + display_id = _new_id() + self.display_id = display_id + + def __repr__(self): + return "<%s display_id=%s>" % (self.__class__.__name__, self.display_id) + + def display(self, obj, **kwargs): + """Make a new display with my id, updating existing instances. + + Parameters + ---------- + + obj: + object to display + **kwargs: + additional keyword arguments passed to display + """ + display(obj, display_id=self.display_id, **kwargs) + + def update(self, obj, **kwargs): + """Update existing displays with my id + + Parameters + ---------- + + obj: + object to display + **kwargs: + additional keyword arguments passed to update_display + """ + update_display(obj, display_id=self.display_id, **kwargs) + + def display_pretty(*objs, **kwargs): """Display the pretty (default) representation of an object. @@ -664,8 +664,8 @@ class TextDisplayObject(DisplayObject): class Pretty(TextDisplayObject): - def _repr_pretty_(self, pp, cycle): - return pp.text(self.data) + def _repr_pretty_(self, pp, cycle): + return pp.text(self.data) class HTML(TextDisplayObject): @@ -703,7 +703,7 @@ class Latex(TextDisplayObject): class SVG(DisplayObject): - _read_flags = 'rb' + _read_flags = 'rb' # wrap data in a property, which extracts the <svg> tag, discarding # document headers _data = None @@ -735,68 +735,68 @@ class SVG(DisplayObject): def _repr_svg_(self): return self.data -class ProgressBar(DisplayObject): - """Progressbar supports displaying a progressbar like element - """ - def __init__(self, total): - """Creates a new progressbar - - Parameters - ---------- - total : int - maximum size of the progressbar - """ - self.total = total - self._progress = 0 - self.html_width = '60ex' - self.text_width = 60 - self._display_id = hexlify(os.urandom(8)).decode('ascii') - - def __repr__(self): - fraction = self.progress / self.total - filled = '=' * int(fraction * self.text_width) - rest = ' ' * (self.text_width - len(filled)) - return '[{}{}] {}/{}'.format( - filled, rest, - self.progress, self.total, - ) - - def _repr_html_(self): - return "<progress style='width:{}' max='{}' value='{}'></progress>".format( - self.html_width, self.total, self.progress) - - def display(self): - display(self, display_id=self._display_id) - - def update(self): - display(self, display_id=self._display_id, update=True) - - @property - def progress(self): - return self._progress - - @progress.setter - def progress(self, value): - self._progress = value - self.update() - - def __iter__(self): - self.display() - self._progress = -1 # First iteration is 0 - return self - - def __next__(self): - """Returns current value and increments display by one.""" - self.progress += 1 - if self.progress < self.total: - return self.progress - else: - raise StopIteration() - - def next(self): - """Python 2 compatibility""" - return self.__next__() - +class ProgressBar(DisplayObject): + """Progressbar supports displaying a progressbar like element + """ + def __init__(self, total): + """Creates a new progressbar + + Parameters + ---------- + total : int + maximum size of the progressbar + """ + self.total = total + self._progress = 0 + self.html_width = '60ex' + self.text_width = 60 + self._display_id = hexlify(os.urandom(8)).decode('ascii') + + def __repr__(self): + fraction = self.progress / self.total + filled = '=' * int(fraction * self.text_width) + rest = ' ' * (self.text_width - len(filled)) + return '[{}{}] {}/{}'.format( + filled, rest, + self.progress, self.total, + ) + + def _repr_html_(self): + return "<progress style='width:{}' max='{}' value='{}'></progress>".format( + self.html_width, self.total, self.progress) + + def display(self): + display(self, display_id=self._display_id) + + def update(self): + display(self, display_id=self._display_id, update=True) + + @property + def progress(self): + return self._progress + + @progress.setter + def progress(self, value): + self._progress = value + self.update() + + def __iter__(self): + self.display() + self._progress = -1 # First iteration is 0 + return self + + def __next__(self): + """Returns current value and increments display by one.""" + self.progress += 1 + if self.progress < self.total: + return self.progress + else: + raise StopIteration() + + def next(self): + """Python 2 compatibility""" + return self.__next__() + class JSON(DisplayObject): """JSON expects a JSON-able dict or list @@ -1012,7 +1012,7 @@ class Image(DisplayObject): if ext is not None: if ext == u'jpg' or ext == u'jpeg': format = self._FMT_JPEG - elif ext == u'png': + elif ext == u'png': format = self._FMT_PNG else: format = ext.lower() diff --git a/contrib/python/ipython/py2/IPython/core/displayhook.py b/contrib/python/ipython/py2/IPython/core/displayhook.py index 50aaa7a50c..cce7c83d16 100644 --- a/contrib/python/ipython/py2/IPython/core/displayhook.py +++ b/contrib/python/ipython/py2/IPython/core/displayhook.py @@ -45,7 +45,7 @@ class DisplayHook(Configurable): self.do_full_cache = 0 cache_size = 0 warn('caching was disabled (min value for cache size is %s).' % - cache_size_min,stacklevel=3) + cache_size_min,stacklevel=3) else: self.do_full_cache = 1 @@ -293,17 +293,17 @@ class DisplayHook(Configurable): # IronPython blocks here forever if sys.platform != "cli": gc.collect() - - -class CapturingDisplayHook(object): - def __init__(self, shell, outputs=None): - self.shell = shell - if outputs is None: - outputs = [] - self.outputs = outputs - - def __call__(self, result=None): - if result is None: - return - format_dict, md_dict = self.shell.display_formatter.format(result) - self.outputs.append({ 'data': format_dict, 'metadata': md_dict }) + + +class CapturingDisplayHook(object): + def __init__(self, shell, outputs=None): + self.shell = shell + if outputs is None: + outputs = [] + self.outputs = outputs + + def __call__(self, result=None): + if result is None: + return + format_dict, md_dict = self.shell.display_formatter.format(result) + self.outputs.append({ 'data': format_dict, 'metadata': md_dict }) diff --git a/contrib/python/ipython/py2/IPython/core/displaypub.py b/contrib/python/ipython/py2/IPython/core/displaypub.py index cb60efb52a..82a859ae15 100644 --- a/contrib/python/ipython/py2/IPython/core/displaypub.py +++ b/contrib/python/ipython/py2/IPython/core/displaypub.py @@ -53,8 +53,8 @@ class DisplayPublisher(Configurable): if not isinstance(metadata, dict): raise TypeError('metadata must be a dict, got: %r' % data) - # use * to indicate transient, update are keyword-only - def publish(self, data, metadata=None, source=None, **kwargs): + # use * to indicate transient, update are keyword-only + def publish(self, data, metadata=None, source=None, **kwargs): """Publish data and metadata to all frontends. See the ``display_data`` message in the messaging documentation for @@ -90,21 +90,21 @@ class DisplayPublisher(Configurable): the data itself. source : str, deprecated Unused. - transient: dict, keyword-only - A dictionary for transient data. - Data in this dictionary should not be persisted as part of saving this output. - Examples include 'display_id'. - update: bool, keyword-only, default: False - If True, only update existing outputs with the same display_id, - rather than creating a new output. + transient: dict, keyword-only + A dictionary for transient data. + Data in this dictionary should not be persisted as part of saving this output. + Examples include 'display_id'. + update: bool, keyword-only, default: False + If True, only update existing outputs with the same display_id, + rather than creating a new output. """ - # These are kwargs only on Python 3, not used there. - # For consistency and avoid code divergence we leave them here to - # simplify potential backport - transient = kwargs.pop('transient', None) - update = kwargs.pop('update', False) - + # These are kwargs only on Python 3, not used there. + # For consistency and avoid code divergence we leave them here to + # simplify potential backport + transient = kwargs.pop('transient', None) + update = kwargs.pop('update', False) + # The default is to simply write the plain text data using sys.stdout. if 'text/plain' in data: print(data['text/plain']) @@ -121,19 +121,19 @@ class CapturingDisplayPublisher(DisplayPublisher): """A DisplayPublisher that stores""" outputs = List() - def publish(self, data, metadata=None, source=None, **kwargs): - - # These are kwargs only on Python 3, not used there. - # For consistency and avoid code divergence we leave them here to - # simplify potential backport - transient = kwargs.pop('transient', None) - update = kwargs.pop('update', False) - - self.outputs.append({'data':data, 'metadata':metadata, - 'transient':transient, 'update':update}) - + def publish(self, data, metadata=None, source=None, **kwargs): + + # These are kwargs only on Python 3, not used there. + # For consistency and avoid code divergence we leave them here to + # simplify potential backport + transient = kwargs.pop('transient', None) + update = kwargs.pop('update', False) + + self.outputs.append({'data':data, 'metadata':metadata, + 'transient':transient, 'update':update}) + def clear_output(self, wait=False): super(CapturingDisplayPublisher, self).clear_output(wait) - + # empty the list, *do not* reassign a new list - self.outputs.clear() + self.outputs.clear() diff --git a/contrib/python/ipython/py2/IPython/core/excolors.py b/contrib/python/ipython/py2/IPython/core/excolors.py index ed28b9564b..487bde18c8 100644 --- a/contrib/python/ipython/py2/IPython/core/excolors.py +++ b/contrib/python/ipython/py2/IPython/core/excolors.py @@ -3,7 +3,7 @@ Color schemes for exception handling code in IPython. """ -import os +import os import warnings #***************************************************************************** @@ -156,12 +156,12 @@ def exception_colors(): Normal = C.Normal, )) - # Hack: the 'neutral' colours are not very visible on a dark background on - # Windows. Since Windows command prompts have a dark background by default, and - # relatively few users are likely to alter that, we will use the 'Linux' colours, - # designed for a dark background, as the default on Windows. - if os.name == "nt": - ex_colors.add_scheme(ex_colors['Linux'].copy('Neutral')) + # Hack: the 'neutral' colours are not very visible on a dark background on + # Windows. Since Windows command prompts have a dark background by default, and + # relatively few users are likely to alter that, we will use the 'Linux' colours, + # designed for a dark background, as the default on Windows. + if os.name == "nt": + ex_colors.add_scheme(ex_colors['Linux'].copy('Neutral')) return ex_colors @@ -172,8 +172,8 @@ class Deprec(object): def __getattr__(self, name): val = getattr(self.wrapped, name) - warnings.warn("Using ExceptionColors global is deprecated and will be removed in IPython 6.0", - DeprecationWarning, stacklevel=2) + warnings.warn("Using ExceptionColors global is deprecated and will be removed in IPython 6.0", + DeprecationWarning, stacklevel=2) # using getattr after warnings break ipydoctest in weird way for 3.5 return val diff --git a/contrib/python/ipython/py2/IPython/core/formatters.py b/contrib/python/ipython/py2/IPython/core/formatters.py index 964c0e4791..d990619f27 100644 --- a/contrib/python/ipython/py2/IPython/core/formatters.py +++ b/contrib/python/ipython/py2/IPython/core/formatters.py @@ -53,17 +53,17 @@ class DisplayFormatter(Configurable): formatter.enabled = True else: formatter.enabled = False - + ipython_display_formatter = ForwardDeclaredInstance('FormatterABC') @default('ipython_display_formatter') def _default_formatter(self): return IPythonDisplayFormatter(parent=self) - - mimebundle_formatter = ForwardDeclaredInstance('FormatterABC') - @default('mimebundle_formatter') - def _default_mime_formatter(self): - return MimeBundleFormatter(parent=self) - + + mimebundle_formatter = ForwardDeclaredInstance('FormatterABC') + @default('mimebundle_formatter') + def _default_mime_formatter(self): + return MimeBundleFormatter(parent=self) + # A dict of formatter whose keys are format types (MIME types) and whose # values are subclasses of BaseFormatter. formatters = Dict() @@ -93,7 +93,7 @@ class DisplayFormatter(Configurable): By default all format types will be computed. - The following MIME types are usually implemented: + The following MIME types are usually implemented: * text/plain * text/html @@ -110,15 +110,15 @@ class DisplayFormatter(Configurable): ---------- obj : object The Python object whose format data will be computed. - include : list, tuple or set; optional + include : list, tuple or set; optional A list of format type strings (MIME types) to include in the format data dict. If this is set *only* the format types included in this list will be computed. - exclude : list, tuple or set; optional + exclude : list, tuple or set; optional A list of format type string (MIME types) to exclude in the format data dict. If this is set all format types will be computed, except for those included in this argument. - Mimetypes present in exclude will take precedence over the ones in include + Mimetypes present in exclude will take precedence over the ones in include Returns ------- @@ -132,15 +132,15 @@ class DisplayFormatter(Configurable): metadata_dict is a dictionary of metadata about each mime-type output. Its keys will be a strict subset of the keys in format_dict. - - Notes - ----- - - If an object implement `_repr_mimebundle_` as well as various - `_repr_*_`, the data returned by `_repr_mimebundle_` will take - precedence and the corresponding `_repr_*_` for this mimetype will - not be called. - + + Notes + ----- + + If an object implement `_repr_mimebundle_` as well as various + `_repr_*_`, the data returned by `_repr_mimebundle_` will take + precedence and the corresponding `_repr_*_` for this mimetype will + not be called. + """ format_dict = {} md_dict = {} @@ -148,21 +148,21 @@ class DisplayFormatter(Configurable): if self.ipython_display_formatter(obj): # object handled itself, don't proceed return {}, {} - - format_dict, md_dict = self.mimebundle_formatter(obj, include=include, exclude=exclude) - - if format_dict or md_dict: - if include: - format_dict = {k:v for k,v in format_dict.items() if k in include} - md_dict = {k:v for k,v in md_dict.items() if k in include} - if exclude: - format_dict = {k:v for k,v in format_dict.items() if k not in exclude} - md_dict = {k:v for k,v in md_dict.items() if k not in exclude} - + + format_dict, md_dict = self.mimebundle_formatter(obj, include=include, exclude=exclude) + + if format_dict or md_dict: + if include: + format_dict = {k:v for k,v in format_dict.items() if k in include} + md_dict = {k:v for k,v in md_dict.items() if k in include} + if exclude: + format_dict = {k:v for k,v in format_dict.items() if k not in exclude} + md_dict = {k:v for k,v in md_dict.items() if k not in exclude} + for format_type, formatter in self.formatters.items(): - if format_type in format_dict: - # already got it from mimebundle, don't render again - continue + if format_type in format_dict: + # already got it from mimebundle, don't render again + continue if include and format_type not in include: continue if exclude and format_type in exclude: @@ -217,7 +217,7 @@ def catch_format_error(method, self, *args, **kwargs): r = method(self, *args, **kwargs) except NotImplementedError: # don't warn on NotImplementedErrors - return self._check_return(None, args[0]) + return self._check_return(None, args[0]) except Exception: exc_info = sys.exc_info() ip = get_ipython() @@ -225,7 +225,7 @@ def catch_format_error(method, self, *args, **kwargs): ip.showtraceback(exc_info) else: traceback.print_exception(*exc_info) - return self._check_return(None, args[0]) + return self._check_return(None, args[0]) return self._check_return(r, args[0]) @@ -876,7 +876,7 @@ class PDFFormatter(BaseFormatter): _return_type = (bytes, unicode_type) class IPythonDisplayFormatter(BaseFormatter): - """An escape-hatch Formatter for objects that know how to display themselves. + """An escape-hatch Formatter for objects that know how to display themselves. To define the callables that compute the representation of your objects, define a :meth:`_ipython_display_` method or use the :meth:`for_type` @@ -886,13 +886,13 @@ class IPythonDisplayFormatter(BaseFormatter): This display formatter has highest priority. If it fires, no other display formatter will be called. - - Prior to IPython 6.1, `_ipython_display_` was the only way to display custom mime-types - without registering a new Formatter. - - IPython 6.1 introduces `_repr_mimebundle_` for displaying custom mime-types, - so `_ipython_display_` should only be used for objects that require unusual - display patterns, such as multiple display calls. + + Prior to IPython 6.1, `_ipython_display_` was the only way to display custom mime-types + without registering a new Formatter. + + IPython 6.1 introduces `_repr_mimebundle_` for displaying custom mime-types, + so `_ipython_display_` should only be used for objects that require unusual + display patterns, such as multiple display calls. """ print_method = ObjectName('_ipython_display_') _return_type = (type(None), bool) @@ -916,63 +916,63 @@ class IPythonDisplayFormatter(BaseFormatter): return True -class MimeBundleFormatter(BaseFormatter): - """A Formatter for arbitrary mime-types. - - Unlike other `_repr_<mimetype>_` methods, - `_repr_mimebundle_` should return mime-bundle data, - either the mime-keyed `data` dictionary or the tuple `(data, metadata)`. - Any mime-type is valid. - - To define the callables that compute the mime-bundle representation of your - objects, define a :meth:`_repr_mimebundle_` method or use the :meth:`for_type` - or :meth:`for_type_by_name` methods to register functions that handle - this. - - .. versionadded:: 6.1 - """ - print_method = ObjectName('_repr_mimebundle_') - _return_type = dict - - def _check_return(self, r, obj): - r = super(MimeBundleFormatter, self)._check_return(r, obj) - # always return (data, metadata): - if r is None: - return {}, {} - if not isinstance(r, tuple): - return r, {} - return r - - @catch_format_error - def __call__(self, obj, include=None, exclude=None): - """Compute the format for an object. - - Identical to parent's method but we pass extra parameters to the method. - - Unlike other _repr_*_ `_repr_mimebundle_` should allow extra kwargs, in - particular `include` and `exclude`. - """ - if self.enabled: - # lookup registered printer - try: - printer = self.lookup(obj) - except KeyError: - pass - else: - return printer(obj) - # Finally look for special method names - method = get_real_method(obj, self.print_method) - - if method is not None: - d = {} - d['include'] = include - d['exclude'] = exclude - return method(**d) - return None - else: - return None - - +class MimeBundleFormatter(BaseFormatter): + """A Formatter for arbitrary mime-types. + + Unlike other `_repr_<mimetype>_` methods, + `_repr_mimebundle_` should return mime-bundle data, + either the mime-keyed `data` dictionary or the tuple `(data, metadata)`. + Any mime-type is valid. + + To define the callables that compute the mime-bundle representation of your + objects, define a :meth:`_repr_mimebundle_` method or use the :meth:`for_type` + or :meth:`for_type_by_name` methods to register functions that handle + this. + + .. versionadded:: 6.1 + """ + print_method = ObjectName('_repr_mimebundle_') + _return_type = dict + + def _check_return(self, r, obj): + r = super(MimeBundleFormatter, self)._check_return(r, obj) + # always return (data, metadata): + if r is None: + return {}, {} + if not isinstance(r, tuple): + return r, {} + return r + + @catch_format_error + def __call__(self, obj, include=None, exclude=None): + """Compute the format for an object. + + Identical to parent's method but we pass extra parameters to the method. + + Unlike other _repr_*_ `_repr_mimebundle_` should allow extra kwargs, in + particular `include` and `exclude`. + """ + if self.enabled: + # lookup registered printer + try: + printer = self.lookup(obj) + except KeyError: + pass + else: + return printer(obj) + # Finally look for special method names + method = get_real_method(obj, self.print_method) + + if method is not None: + d = {} + d['include'] = include + d['exclude'] = exclude + return method(**d) + return None + else: + return None + + FormatterABC.register(BaseFormatter) FormatterABC.register(PlainTextFormatter) FormatterABC.register(HTMLFormatter) @@ -985,7 +985,7 @@ FormatterABC.register(LatexFormatter) FormatterABC.register(JSONFormatter) FormatterABC.register(JavascriptFormatter) FormatterABC.register(IPythonDisplayFormatter) -FormatterABC.register(MimeBundleFormatter) +FormatterABC.register(MimeBundleFormatter) def format_display_data(obj, include=None, exclude=None): diff --git a/contrib/python/ipython/py2/IPython/core/history.py b/contrib/python/ipython/py2/IPython/core/history.py index 894f927f7a..2e7fdbc845 100644 --- a/contrib/python/ipython/py2/IPython/core/history.py +++ b/contrib/python/ipython/py2/IPython/core/history.py @@ -21,7 +21,7 @@ import threading from traitlets.config.configurable import LoggingConfigurable from decorator import decorator from IPython.utils.decorators import undoc -from IPython.paths import locate_profile +from IPython.paths import locate_profile from IPython.utils import py3compat from traitlets import ( Any, Bool, Dict, Instance, Integer, List, Unicode, TraitError, @@ -301,8 +301,8 @@ class HistoryAccessor(HistoryAccessorBase): cur = self.db.execute("SELECT session, line, %s FROM %s " %\ (toget, sqlfrom) + sql, params) if output: # Regroup into 3-tuples, and parse JSON - return ((ses, lin, (py3compat.cast_unicode_py2(inp), py3compat.cast_unicode_py2(out))) - for ses, lin, inp, out in cur) + return ((ses, lin, (py3compat.cast_unicode_py2(inp), py3compat.cast_unicode_py2(out))) + for ses, lin, inp, out in cur) return cur @needs_sqlite diff --git a/contrib/python/ipython/py2/IPython/core/hooks.py b/contrib/python/ipython/py2/IPython/core/hooks.py index 482a44a79e..e6fc84087f 100644 --- a/contrib/python/ipython/py2/IPython/core/hooks.py +++ b/contrib/python/ipython/py2/IPython/core/hooks.py @@ -99,7 +99,7 @@ def fix_error_editor(self,filename,linenum,column,msg): in future versions. It appears to be used only for automatically fixing syntax error that has been broken for a few years and has thus been removed. If you happend to use this function and still need it please make your voice heard on -the mailing list ipython-dev@python.org , or on the GitHub Issue tracker: +the mailing list ipython-dev@python.org , or on the GitHub Issue tracker: https://github.com/ipython/ipython/issues/9649 """, UserWarning) def vim_quickfix_file(): diff --git a/contrib/python/ipython/py2/IPython/core/inputtransformer.py b/contrib/python/ipython/py2/IPython/core/inputtransformer.py index b321e3c1ba..3ba49b951d 100644 --- a/contrib/python/ipython/py2/IPython/core/inputtransformer.py +++ b/contrib/python/ipython/py2/IPython/core/inputtransformer.py @@ -126,19 +126,19 @@ class TokenInputTransformer(InputTransformer): """ def __init__(self, func): self.func = func - self.buf = [] + self.buf = [] self.reset_tokenizer() - + def reset_tokenizer(self): - it = iter(self.buf) - nxt = it.__next__ if PY3 else it.next - self.tokenizer = generate_tokens(nxt) - + it = iter(self.buf) + nxt = it.__next__ if PY3 else it.next + self.tokenizer = generate_tokens(nxt) + def push(self, line): - self.buf.append(line + '\n') - if all(l.isspace() for l in self.buf): + self.buf.append(line + '\n') + if all(l.isspace() for l in self.buf): return self.reset() - + tokens = [] stop_at_NL = False try: @@ -158,13 +158,13 @@ class TokenInputTransformer(InputTransformer): return self.output(tokens) def output(self, tokens): - self.buf[:] = [] + self.buf[:] = [] self.reset_tokenizer() return untokenize(self.func(tokens)).rstrip('\n') def reset(self): - l = ''.join(self.buf) - self.buf[:] = [] + l = ''.join(self.buf) + self.buf[:] = [] self.reset_tokenizer() if l: return l.rstrip('\n') diff --git a/contrib/python/ipython/py2/IPython/core/interactiveshell.py b/contrib/python/ipython/py2/IPython/core/interactiveshell.py index 52d80fceeb..ad8824b606 100644 --- a/contrib/python/ipython/py2/IPython/core/interactiveshell.py +++ b/contrib/python/ipython/py2/IPython/core/interactiveshell.py @@ -58,7 +58,7 @@ from IPython.core.prefilter import PrefilterManager from IPython.core.profiledir import ProfileDir from IPython.core.usage import default_banner from IPython.testing.skipdoctest import skip_doctest_py2, skip_doctest -from IPython.display import display +from IPython.display import display from IPython.utils import PyColorize from IPython.utils import io from IPython.utils import py3compat @@ -637,7 +637,7 @@ class InteractiveShell(SingletonConfigurable): # removing on exit or representing the existence of more than one # IPython at a time. builtin_mod.__dict__['__IPYTHON__'] = True - builtin_mod.__dict__['display'] = display + builtin_mod.__dict__['display'] = display self.builtin_trap = BuiltinTrap(shell=self) @@ -2064,7 +2064,7 @@ class InteractiveShell(SingletonConfigurable): etpl = "Line magic function `%%%s` not found%s." extra = '' if cm is None else (' (But cell magic `%%%%%s` exists, ' 'did you mean that instead?)' % magic_name ) - raise UsageError(etpl % (magic_name, extra)) + raise UsageError(etpl % (magic_name, extra)) else: # Note: this is the distance in the stack to the user's frame. # This will need to be updated if the internal calling logic gets @@ -2101,7 +2101,7 @@ class InteractiveShell(SingletonConfigurable): etpl = "Cell magic `%%{0}` not found{1}." extra = '' if lm is None else (' (But line magic `%{0}` exists, ' 'did you mean that instead?)'.format(magic_name)) - raise UsageError(etpl.format(magic_name, extra)) + raise UsageError(etpl.format(magic_name, extra)) elif cell == '': message = '%%{0} is a cell magic, but the cell body is empty.'.format(magic_name) if self.find_line_magic(magic_name) is not None: @@ -2537,12 +2537,12 @@ class InteractiveShell(SingletonConfigurable): """generator for sequence of code blocks to run""" if fname.endswith('.ipynb'): from nbformat import read - nb = read(fname, as_version=4) - if not nb.cells: - return - for cell in nb.cells: - if cell.cell_type == 'code': - yield cell.source + nb = read(fname, as_version=4) + if not nb.cells: + return + for cell in nb.cells: + if cell.cell_type == 'code': + yield cell.source else: with open(fname) as f: yield f.read() @@ -2626,8 +2626,8 @@ class InteractiveShell(SingletonConfigurable): result.execution_count = self.execution_count def error_before_exec(value): - if store_history: - self.execution_count += 1 + if store_history: + self.execution_count += 1 result.error_before_exec = value self.last_execution_succeeded = False return result @@ -2900,32 +2900,32 @@ class InteractiveShell(SingletonConfigurable): # For backwards compatibility runcode = run_code - def check_complete(self, code): - """Return whether a block of code is ready to execute, or should be continued - - Parameters - ---------- - source : string - Python input code, which can be multiline. - - Returns - ------- - status : str - One of 'complete', 'incomplete', or 'invalid' if source is not a - prefix of valid code. - indent : str - When status is 'incomplete', this is some whitespace to insert on - the next line of the prompt. - """ - status, nspaces = self.input_splitter.check_complete(code) - return status, ' ' * (nspaces or 0) - + def check_complete(self, code): + """Return whether a block of code is ready to execute, or should be continued + + Parameters + ---------- + source : string + Python input code, which can be multiline. + + Returns + ------- + status : str + One of 'complete', 'incomplete', or 'invalid' if source is not a + prefix of valid code. + indent : str + When status is 'incomplete', this is some whitespace to insert on + the next line of the prompt. + """ + status, nspaces = self.input_splitter.check_complete(code) + return status, ' ' * (nspaces or 0) + #------------------------------------------------------------------------- # Things related to GUI support and pylab #------------------------------------------------------------------------- - active_eventloop = None - + active_eventloop = None + def enable_gui(self, gui=None): raise NotImplementedError('Implement enable_gui in a subclass') diff --git a/contrib/python/ipython/py2/IPython/core/magics/basic.py b/contrib/python/ipython/py2/IPython/core/magics/basic.py index 304bf4228c..ca69e2e698 100644 --- a/contrib/python/ipython/py2/IPython/core/magics/basic.py +++ b/contrib/python/ipython/py2/IPython/core/magics/basic.py @@ -3,7 +3,7 @@ from __future__ import print_function from __future__ import absolute_import -import argparse +import argparse import io import sys from pprint import pformat @@ -288,14 +288,14 @@ Currently the magic system has the following functions:""", @line_magic def profile(self, parameter_s=''): - """DEPRECATED since IPython 2.0. + """DEPRECATED since IPython 2.0. + + Raise `UsageError`. To profile code use the :magic:`prun` magic. + - Raise `UsageError`. To profile code use the :magic:`prun` magic. - - See Also -------- - prun : run code using the Python profiler (:magic:`prun`) + prun : run code using the Python profiler (:magic:`prun`) """ warn("%profile is now deprecated. Please use get_ipython().profile instead.") from IPython.core.application import BaseIPythonApplication @@ -551,7 +551,7 @@ Currently the magic system has the following functions:""", @magic_arguments.magic_arguments() @magic_arguments.argument( '-e', '--export', action='store_true', default=False, - help=argparse.SUPPRESS + help=argparse.SUPPRESS ) @magic_arguments.argument( 'filename', type=unicode_type, @@ -562,24 +562,24 @@ Currently the magic system has the following functions:""", """Export and convert IPython notebooks. This function can export the current IPython history to a notebook file. - For example, to export the history to "foo.ipynb" do "%notebook foo.ipynb". - - The -e or --export flag is deprecated in IPython 5.2, and will be - removed in the future. + For example, to export the history to "foo.ipynb" do "%notebook foo.ipynb". + + The -e or --export flag is deprecated in IPython 5.2, and will be + removed in the future. """ args = magic_arguments.parse_argstring(self.notebook, s) from nbformat import write, v4 - - cells = [] - hist = list(self.shell.history_manager.get_range()) - if(len(hist)<=1): - raise ValueError('History is empty, cannot export') - for session, execution_count, source in hist[:-1]: - cells.append(v4.new_code_cell( - execution_count=execution_count, - source=source - )) - nb = v4.new_notebook(cells=cells) - with io.open(args.filename, 'w', encoding='utf-8') as f: - write(nb, f, version=4) + + cells = [] + hist = list(self.shell.history_manager.get_range()) + if(len(hist)<=1): + raise ValueError('History is empty, cannot export') + for session, execution_count, source in hist[:-1]: + cells.append(v4.new_code_cell( + execution_count=execution_count, + source=source + )) + nb = v4.new_notebook(cells=cells) + with io.open(args.filename, 'w', encoding='utf-8') as f: + write(nb, f, version=4) diff --git a/contrib/python/ipython/py2/IPython/core/magics/execution.py b/contrib/python/ipython/py2/IPython/core/magics/execution.py index 73f7581cb6..3734b0cdae 100644 --- a/contrib/python/ipython/py2/IPython/core/magics/execution.py +++ b/contrib/python/ipython/py2/IPython/core/magics/execution.py @@ -437,7 +437,7 @@ python-profiler package from non-free.""") def _debug_exec(self, code, breakpoint): if breakpoint: - (filename, bp_line) = breakpoint.rsplit(':', 1) + (filename, bp_line) = breakpoint.rsplit(':', 1) bp_line = int(bp_line) else: (filename, bp_line) = (None, None) @@ -806,17 +806,17 @@ python-profiler package from non-free.""") self.shell.InteractiveTB.pdb = self.shell.InteractiveTB.debugger_cls() deb = self.shell.InteractiveTB.pdb - # deb.checkline() fails if deb.curframe exists but is None; it can - # handle it not existing. https://github.com/ipython/ipython/issues/10028 - if hasattr(deb, 'curframe'): - del deb.curframe - + # deb.checkline() fails if deb.curframe exists but is None; it can + # handle it not existing. https://github.com/ipython/ipython/issues/10028 + if hasattr(deb, 'curframe'): + del deb.curframe + # reset Breakpoint state, which is moronically kept # in a class bdb.Breakpoint.next = 1 bdb.Breakpoint.bplist = {} bdb.Breakpoint.bpbynumber = [None] - deb.clear_all_breaks() + deb.clear_all_breaks() if bp_line is not None: # Set an initial breakpoint to stop execution maxtries = 10 @@ -1013,13 +1013,13 @@ python-profiler package from non-free.""") ast_setup = self.shell.transform_ast(ast_setup) ast_stmt = self.shell.transform_ast(ast_stmt) - # Check that these compile to valid Python code *outside* the timer func - # Invalid code may become valid when put inside the function & loop, - # which messes up error messages. - # https://github.com/ipython/ipython/issues/10636 - self.shell.compile(ast_setup, "<magic-timeit-setup>", "exec") - self.shell.compile(ast_stmt, "<magic-timeit-stmt>", "exec") - + # Check that these compile to valid Python code *outside* the timer func + # Invalid code may become valid when put inside the function & loop, + # which messes up error messages. + # https://github.com/ipython/ipython/issues/10636 + self.shell.compile(ast_setup, "<magic-timeit-setup>", "exec") + self.shell.compile(ast_stmt, "<magic-timeit-stmt>", "exec") + # This codestring is taken from timeit.template - we fill it in as an # AST, so that we can apply our AST transformations to the user code # without affecting the timing code. diff --git a/contrib/python/ipython/py2/IPython/core/magics/script.py b/contrib/python/ipython/py2/IPython/core/magics/script.py index 22e6c46579..3fbddc38a8 100644 --- a/contrib/python/ipython/py2/IPython/core/magics/script.py +++ b/contrib/python/ipython/py2/IPython/core/magics/script.py @@ -246,8 +246,8 @@ class ScriptMagics(Magics): def kill_bg_processes(self): """Kill all BG processes which are still running.""" - if not self.bg_processes: - return + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: @@ -255,9 +255,9 @@ class ScriptMagics(Magics): except: pass time.sleep(0.1) - self._gc_bg_processes() - if not self.bg_processes: - return + self._gc_bg_processes() + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: @@ -265,9 +265,9 @@ class ScriptMagics(Magics): except: pass time.sleep(0.1) - self._gc_bg_processes() - if not self.bg_processes: - return + self._gc_bg_processes() + if not self.bg_processes: + return for p in self.bg_processes: if p.poll() is None: try: diff --git a/contrib/python/ipython/py2/IPython/core/oinspect.py b/contrib/python/ipython/py2/IPython/core/oinspect.py index 0360a9c98f..55a4efe8c0 100644 --- a/contrib/python/ipython/py2/IPython/core/oinspect.py +++ b/contrib/python/ipython/py2/IPython/core/oinspect.py @@ -651,7 +651,7 @@ class Inspector(Colorable): # Functions, methods, classes append_field(_mime, 'Signature', 'definition', code_formatter) append_field(_mime, 'Init signature', 'init_definition', code_formatter) - if detail_level > 0 and info['source']: + if detail_level > 0 and info['source']: append_field(_mime, 'Source', 'source', code_formatter) else: append_field(_mime, 'Docstring', 'docstring', formatter) @@ -662,9 +662,9 @@ class Inspector(Colorable): else: # General Python objects - append_field(_mime, 'Signature', 'definition', code_formatter) - append_field(_mime, 'Call signature', 'call_def', code_formatter) - + append_field(_mime, 'Signature', 'definition', code_formatter) + append_field(_mime, 'Call signature', 'call_def', code_formatter) + append_field(_mime, 'Type', 'type_name') # Base class for old-style instances @@ -678,8 +678,8 @@ class Inspector(Colorable): append_field(_mime, 'Namespace', 'namespace') append_field(_mime, 'Length', 'length') - append_field(_mime, 'File', 'file') - + append_field(_mime, 'File', 'file') + # Source or docstring, depending on detail level and whether # source found. if detail_level > 0: @@ -690,7 +690,7 @@ class Inspector(Colorable): append_field(_mime, 'Class docstring', 'class_docstring', formatter) append_field(_mime, 'Init docstring', 'init_docstring', formatter) append_field(_mime, 'Call docstring', 'call_docstring', formatter) - + return self.format_mime(_mime) diff --git a/contrib/python/ipython/py2/IPython/core/pylabtools.py b/contrib/python/ipython/py2/IPython/core/pylabtools.py index 63c38b4386..a1932d8c48 100644 --- a/contrib/python/ipython/py2/IPython/core/pylabtools.py +++ b/contrib/python/ipython/py2/IPython/core/pylabtools.py @@ -19,18 +19,18 @@ backends = {'tk': 'TkAgg', 'wx': 'WXAgg', 'qt4': 'Qt4Agg', 'qt5': 'Qt5Agg', - 'qt': 'Qt5Agg', + 'qt': 'Qt5Agg', 'osx': 'MacOSX', 'nbagg': 'nbAgg', 'notebook': 'nbAgg', - 'agg': 'agg', - 'svg': 'svg', - 'pdf': 'pdf', - 'ps': 'ps', - 'inline': 'module://ipykernel.pylab.backend_inline', - 'ipympl': 'module://ipympl.backend_nbagg', - 'widget': 'module://ipympl.backend_nbagg', - } + 'agg': 'agg', + 'svg': 'svg', + 'pdf': 'pdf', + 'ps': 'ps', + 'inline': 'module://ipykernel.pylab.backend_inline', + 'ipympl': 'module://ipympl.backend_nbagg', + 'widget': 'module://ipympl.backend_nbagg', + } # We also need a reverse backends2guis mapping that will properly choose which # GUI support to activate based on the desired matplotlib backend. For the @@ -45,13 +45,13 @@ backend2gui['GTK'] = backend2gui['GTKCairo'] = 'gtk' backend2gui['GTK3Cairo'] = 'gtk3' backend2gui['WX'] = 'wx' backend2gui['CocoaAgg'] = 'osx' -# And some backends that don't need GUI integration -del backend2gui['nbAgg'] -del backend2gui['agg'] -del backend2gui['svg'] -del backend2gui['pdf'] -del backend2gui['ps'] -del backend2gui['module://ipykernel.pylab.backend_inline'] +# And some backends that don't need GUI integration +del backend2gui['nbAgg'] +del backend2gui['agg'] +del backend2gui['svg'] +del backend2gui['pdf'] +del backend2gui['ps'] +del backend2gui['module://ipykernel.pylab.backend_inline'] #----------------------------------------------------------------------------- # Matplotlib utilities @@ -111,7 +111,7 @@ def print_figure(fig, fmt='png', bbox_inches='tight', **kwargs): if not fig.axes and not fig.lines: return - dpi = fig.dpi + dpi = fig.dpi if fmt == 'retina': dpi = dpi * 2 fmt = 'png' @@ -171,7 +171,7 @@ def mpl_runner(safe_execfile): properly handle interactive rendering.""" import matplotlib - import matplotlib.pyplot as plt + import matplotlib.pyplot as plt #print '*** Matplotlib runner ***' # dbg # turn off rendering until end of script @@ -180,18 +180,18 @@ def mpl_runner(safe_execfile): safe_execfile(fname,*where,**kw) matplotlib.interactive(is_interactive) # make rendering call now, if the user tried to do it - if plt.draw_if_interactive.called: - plt.draw() - plt.draw_if_interactive.called = False - - # re-draw everything that is stale - try: - da = plt.draw_all - except AttributeError: - pass - else: - da() - + if plt.draw_if_interactive.called: + plt.draw() + plt.draw_if_interactive.called = False + + # re-draw everything that is stale + try: + da = plt.draw_all + except AttributeError: + pass + else: + da() + return mpl_execfile @@ -231,8 +231,8 @@ def select_figure_formats(shell, formats, **kwargs): formats = set(formats) [ f.pop(Figure, None) for f in shell.display_formatter.formatters.values() ] - mplbackend = matplotlib.get_backend().lower() - if mplbackend == 'nbagg' or mplbackend == 'module://ipympl.backend_nbagg': + mplbackend = matplotlib.get_backend().lower() + if mplbackend == 'nbagg' or mplbackend == 'module://ipympl.backend_nbagg': formatter = shell.display_formatter.ipython_display_formatter formatter.for_type(Figure, _reshow_nbagg_figure) @@ -316,12 +316,12 @@ def activate_matplotlib(backend): # This must be imported last in the matplotlib series, after # backend/interactivity choices have been made - import matplotlib.pyplot as plt + import matplotlib.pyplot as plt - plt.show._needmain = False + plt.show._needmain = False # We need to detect at runtime whether show() is called by the user. # For this, we wrap it into a decorator which adds a 'called' flag. - plt.draw_if_interactive = flag_calls(plt.draw_if_interactive) + plt.draw_if_interactive = flag_calls(plt.draw_if_interactive) def import_pylab(user_ns, import_all=True): diff --git a/contrib/python/ipython/py2/IPython/core/release.py b/contrib/python/ipython/py2/IPython/core/release.py index 494e7e41ee..94dea1073b 100644 --- a/contrib/python/ipython/py2/IPython/core/release.py +++ b/contrib/python/ipython/py2/IPython/core/release.py @@ -101,9 +101,9 @@ authors = {'Fernando' : ('Fernando Perez','fperez.net@gmail.com'), author = 'The IPython Development Team' -author_email = 'ipython-dev@python.org' +author_email = 'ipython-dev@python.org' -url = 'https://ipython.org' +url = 'https://ipython.org' platforms = ['Linux','Mac OSX','Windows'] diff --git a/contrib/python/ipython/py2/IPython/core/shellapp.py b/contrib/python/ipython/py2/IPython/core/shellapp.py index 43b900ea5a..213648246e 100644 --- a/contrib/python/ipython/py2/IPython/core/shellapp.py +++ b/contrib/python/ipython/py2/IPython/core/shellapp.py @@ -11,14 +11,14 @@ from __future__ import absolute_import from __future__ import print_function import glob -from itertools import chain +from itertools import chain import os import sys from traitlets.config.application import boolean_flag from traitlets.config.configurable import Configurable from traitlets.config.loader import Config -from IPython.core.application import SYSTEM_CONFIG_DIRS, ENV_CONFIG_DIRS +from IPython.core.application import SYSTEM_CONFIG_DIRS, ENV_CONFIG_DIRS from IPython.core import pylabtools from IPython.utils import py3compat from IPython.utils.contexts import preserve_keys @@ -333,9 +333,9 @@ class InteractiveShellApp(Configurable): def _run_startup_files(self): """Run files from profile startup directory""" - startup_dirs = [self.profile_dir.startup_dir] + [ - os.path.join(p, 'startup') for p in chain(ENV_CONFIG_DIRS, SYSTEM_CONFIG_DIRS) - ] + startup_dirs = [self.profile_dir.startup_dir] + [ + os.path.join(p, 'startup') for p in chain(ENV_CONFIG_DIRS, SYSTEM_CONFIG_DIRS) + ] startup_files = [] if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \ @@ -347,9 +347,9 @@ class InteractiveShellApp(Configurable): except: self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup) self.shell.showtraceback() - for startup_dir in startup_dirs[::-1]: - startup_files += glob.glob(os.path.join(startup_dir, '*.py')) - startup_files += glob.glob(os.path.join(startup_dir, '*.ipy')) + for startup_dir in startup_dirs[::-1]: + startup_files += glob.glob(os.path.join(startup_dir, '*.py')) + startup_files += glob.glob(os.path.join(startup_dir, '*.ipy')) if not startup_files: return diff --git a/contrib/python/ipython/py2/IPython/core/ultratb.py b/contrib/python/ipython/py2/IPython/core/ultratb.py index 2977e9109b..a855145825 100644 --- a/contrib/python/ipython/py2/IPython/core/ultratb.py +++ b/contrib/python/ipython/py2/IPython/core/ultratb.py @@ -438,7 +438,7 @@ def is_recursion_error(etype, value, records): # by stack frames in IPython itself. >500 frames probably indicates # a recursion error. return (etype is recursion_error_type) \ - and str("recursion") in str(value).lower() \ + and str("recursion") in str(value).lower() \ and len(records) > 500 def find_recursion(etype, value, records): @@ -1130,12 +1130,12 @@ class VerboseTB(TBTools): # problems, but it generates empty tracebacks for console errors # (5 blanks lines) where none should be returned. return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset) - except UnicodeDecodeError: - # This can occur if a file's encoding magic comment is wrong. - # I can't see a way to recover without duplicating a bunch of code - # from the stdlib traceback module. --TK - error('\nUnicodeDecodeError while processing traceback.\n') - return None + except UnicodeDecodeError: + # This can occur if a file's encoding magic comment is wrong. + # I can't see a way to recover without duplicating a bunch of code + # from the stdlib traceback module. --TK + error('\nUnicodeDecodeError while processing traceback.\n') + return None except: # FIXME: I've been getting many crash reports from python 2.3 # users, traceable to inspect.py. If I can find a small test-case @@ -1227,7 +1227,7 @@ class VerboseTB(TBTools): if force or self.call_pdb: if self.pdb is None: - self.pdb = self.debugger_cls() + self.pdb = self.debugger_cls() # the system displayhook may have changed, restore the original # for pdb display_trap = DisplayTrap(hook=sys.__displayhook__) diff --git a/contrib/python/ipython/py2/IPython/core/usage.py b/contrib/python/ipython/py2/IPython/core/usage.py index 0ad963646d..c4d3c16eca 100644 --- a/contrib/python/ipython/py2/IPython/core/usage.py +++ b/contrib/python/ipython/py2/IPython/core/usage.py @@ -67,9 +67,9 @@ interactive_usage = """ IPython -- An enhanced Interactive Python ========================================= -IPython offers a fully compatible replacement for the standard Python -interpreter, with convenient shell features, special commands, command -history mechanism and output results caching. +IPython offers a fully compatible replacement for the standard Python +interpreter, with convenient shell features, special commands, command +history mechanism and output results caching. At your system command line, type 'ipython -h' to see the command line options available. This document only describes interactive features. @@ -77,8 +77,8 @@ options available. This document only describes interactive features. MAIN FEATURES ------------- -* Access to the standard Python help with object docstrings and the Python - manuals. Simply type 'help' (no quotes) to invoke it. +* Access to the standard Python help with object docstrings and the Python + manuals. Simply type 'help' (no quotes) to invoke it. * Magic commands: type %magic for information on the magic subsystem. @@ -86,12 +86,12 @@ MAIN FEATURES * Dynamic object information: - Typing ?word or word? prints detailed information about an object. Certain - long strings (code, etc.) get snipped in the center for brevity. + Typing ?word or word? prints detailed information about an object. Certain + long strings (code, etc.) get snipped in the center for brevity. Typing ??word or word?? gives access to the full information without - snipping long strings. Strings that are longer than the screen are printed - through the less pager. + snipping long strings. Strings that are longer than the screen are printed + through the less pager. The ?/?? system gives access to the full source code for any object (if available), shows function prototypes and other useful information. @@ -99,16 +99,16 @@ MAIN FEATURES If you just want to see an object's docstring, type '%pdoc object' (without quotes, and without % if you have automagic on). -* Tab completion in the local namespace: +* Tab completion in the local namespace: At any time, hitting tab will complete any available python commands or variable names, and show you a list of the possible completions if there's no unambiguous one. It will also complete filenames in the current directory. -* Search previous command history in multiple ways: +* Search previous command history in multiple ways: - - Start typing, and then use arrow keys up/down or (Ctrl-p/Ctrl-n) to search - through the history items that match what you've typed so far. + - Start typing, and then use arrow keys up/down or (Ctrl-p/Ctrl-n) to search + through the history items that match what you've typed so far. - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches your history for lines that match what you've typed so far, completing as @@ -120,7 +120,7 @@ MAIN FEATURES * Logging of input with the ability to save and restore a working session. -* System shell with !. Typing !ls will run 'ls' in the current directory. +* System shell with !. Typing !ls will run 'ls' in the current directory. * The reload command does a 'deep' reload of a module: changes made to the module since you imported will actually be available without having to exit. |