[Python-modules-commits] [jupyter-console] 02/06: Import jupyter-console_5.1.0.orig.tar.gz

Gordon Ball chronitis-guest at moszumanska.debian.org
Fri Feb 3 20:44:56 UTC 2017


This is an automated email from the git hooks/post-receive script.

chronitis-guest pushed a commit to branch master
in repository jupyter-console.

commit 9b8893fc4b251ab7e27ce63876de31680b6ea03a
Author: Gordon Ball <gordon at chronitis.net>
Date:   Fri Feb 3 21:30:52 2017 +0100

    Import jupyter-console_5.1.0.orig.tar.gz
---
 PKG-INFO                     |  2 +-
 README.md                    | 24 ++++++++++++++---
 docs/changelog.rst           | 16 +++++++++++
 docs/conf.py                 | 22 ++++++++++++---
 docs/environment.yml         | 11 ++++++++
 docs/index.rst               |  4 +++
 docs/release.rst             |  8 +-----
 docs/requirements.txt        |  7 +++--
 jupyter_console/_version.py  |  2 +-
 jupyter_console/app.py       | 12 ++++++---
 jupyter_console/completer.py | 39 +--------------------------
 jupyter_console/ptshell.py   | 64 +++++++++++++++++++++++++++++++++-----------
 12 files changed, 135 insertions(+), 76 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 8360427..5ecc2a7 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: jupyter_console
-Version: 5.0.0
+Version: 5.1.0
 Summary: Jupyter terminal console
 Home-page: https://jupyter.org
 Author: Jupyter Development Team
diff --git a/README.md b/README.md
index edcad84..3e6dc72 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,18 @@
 # Jupyter Console
 [![Build Status](https://travis-ci.org/jupyter/jupyter_console.svg?branch=master)](https://travis-ci.org/jupyter/jupyter_console)
-[![Documentation Status](http://readthedocs.org/projects/jupyter-console/badge/?version=latest)](http://jupyter-console.readthedocs.org/en/latest/?badge=latest)
+[![Documentation Status](http://readthedocs.org/projects/jupyter-console/badge/?version=latest)](https://jupyter-console.readthedocs.io/en/latest/?badge=latest)
 
 A terminal-based console frontend for Jupyter kernels.
 This code is based on the single-process IPython terminal.
 
-Install:
+Install with pip:
 
     pip install jupyter-console
 
+Install with conda:
+
+    conda install -c conda-forge jupyter_console
+
 Start:
 
     jupyter console
@@ -17,9 +21,21 @@ Help:
 
     jupyter console -h
 
+Jupyter Console allows for console-based interaction with non-python 
+Jupyter kernels such as IJulia, IRKernel.
+
+To start the console with a particular kernel, ask for it by name::
+
+    jupyter console --kernel=julia-0.4
+
+A list of available kernels can be seen with::
+
+    jupyter kernelspec list
+
+
 ## Resources
 - [Project Jupyter website](https://jupyter.org)
-- [Documentation for Jupyter Console](http://jupyter-console.readthedocs.org/en/latest/) [[PDF](https://media.readthedocs.org/pdf/jupyter-console/latest/jupyter-notebook.pdf)]
-- [Documentation for Project Jupyter](http://jupyter.readthedocs.org/en/latest/index.html) [[PDF](https://media.readthedocs.org/pdf/jupyter/latest/jupyter.pdf)]
+- [Documentation for Jupyter Console](https://jupyter-console.readthedocs.io/en/latest/) [[PDF](https://media.readthedocs.org/pdf/jupyter-console/latest/jupyter-notebook.pdf)]
+- [Documentation for Project Jupyter](https://jupyter.readthedocs.io/en/latest/index.html) [[PDF](https://media.readthedocs.org/pdf/jupyter/latest/jupyter.pdf)]
 - [Issues](https://github.com/jupyter/jupyter_console/issues)
 - [Technical support - Jupyter Google Group](https://groups.google.com/forum/#!forum/jupyter)
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 25d405b..b61c320 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -3,9 +3,25 @@ Changes in Jupyter console
 
 A summary of changes in Jupyter console releases.
 
+5.1
+---
+
+- New ``ZMQTerminalInteractiveShell.true_color`` config option to use 24-bit
+  colour.
+- New ``ZMQTerminalInteractiveShell.confirm_exit`` config option to turn off
+  asking 'are you sure' on exit.
+- New ``--simple-prompt`` flag to explicitly use the fallback mode without
+  prompt_toolkit.
+- Fixed executing an empty input.
+- Fixed formatting for code and outputs from other frontends executing code.
+- Avoid using functions which will be removed in IPython 6.
+
 5.0
 ---
 
+5.0.0
+~~~~~
+
 Interactive Shell architecture
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - disinherit shell class from IPython Interactive Shell `#68 <https://github.com/jupyter/jupyter_console/pull/68>`_
diff --git a/docs/conf.py b/docs/conf.py
index 0d2fcd8..95c633e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -20,7 +20,13 @@ import shlex
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+
+# add repo root to sys.path
+# docs_dir = root/docs
+docsdir = os.path.abspath(os.path.dirname(__file__))
+reporoot = os.path.dirname(os.path.dirname(docsdir))
+sys.path.insert(0, reporoot)
+
 
 if os.environ.get('READTHEDOCS', ''):
     # RTD doesn't use the Makefile, so re-run autogen_config.py here.
@@ -152,7 +158,7 @@ todo_include_todos = False
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
+#html_static_path = ['_static']
 
 # Add any extra paths that contain custom files (such as robots.txt or
 # .htaccess) here, relative to this directory. These files are copied
@@ -300,4 +306,14 @@ texinfo_documents = [
 
 
 # Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {'https://docs.python.org/': None}
+intersphinx_mapping = {'https://docs.python.org/3': None,}
+
+# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if not on_rtd:  # only import and set the theme if we're building docs locally
+    import sphinx_rtd_theme
+    html_theme = 'sphinx_rtd_theme'
+    html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
+
+# otherwise, readthedocs.org uses their theme by default, so no need to specify it
diff --git a/docs/environment.yml b/docs/environment.yml
new file mode 100644
index 0000000..6291983
--- /dev/null
+++ b/docs/environment.yml
@@ -0,0 +1,11 @@
+name: jupyterconsole
+channels:
+  - conda-forge
+  - conda
+dependencies:
+  - python=3
+  - ipython
+  - jupyter_core
+  - jupyter_client
+  - sphinx
+  - sphinx_rtd_theme
diff --git a/docs/index.rst b/docs/index.rst
index 286d65c..d0aa294 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -6,6 +6,10 @@ The console can be installed with::
 
     pip install jupyter-console
 
+If you want to use conda instead to perform your installation::
+
+    conda install -c conda-forge jupyter-console
+
 And started with::
 
     jupyter console
diff --git a/docs/release.rst b/docs/release.rst
index 45a51e7..1574852 100644
--- a/docs/release.rst
+++ b/docs/release.rst
@@ -6,12 +6,6 @@ Making a release as a maintainer
 This document guides a maintainer through creating a release of the Jupyter
 console.
 
-Check installed tools
----------------------
-
-Review ``CONTRIBUTING.rst``. Make sure all the tools needed are properly
-installed.
-
 Clean the repository
 --------------------
 
@@ -51,7 +45,7 @@ Create the release
 
     .. code:: bash
 
-        python setup.py sdist --formats=zip,gztar
+        python setup.py sdist --formats=gztar
         python setup.py bdist_wheel
 
 #.  You can now test the ``wheel`` and the ``sdist`` locally before uploading
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 26d0398..52d1a39 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,2 +1,5 @@
--e git://github.com/ipython/ipython#egg=ipython
--e .
+ipython
+-e ../.
+jupyter_core
+jupyter_client
+sphinx
diff --git a/jupyter_console/_version.py b/jupyter_console/_version.py
index 14c4805..4f23444 100644
--- a/jupyter_console/_version.py
+++ b/jupyter_console/_version.py
@@ -5,6 +5,6 @@ the beta released i.e. 1, 2, 3 ...
 See PEP 440 https://www.python.org/dev/peps/pep-0440/
 """
 
-version_info = (5, 0, 0, '')
+version_info = (5, 1, 0)
 
 __version__ = '.'.join(map(str, version_info[:3])) + ''.join(version_info[3:])
diff --git a/jupyter_console/app.py b/jupyter_console/app.py
index b3d0769..d38e38f 100644
--- a/jupyter_console/app.py
+++ b/jupyter_console/app.py
@@ -16,8 +16,7 @@ import sys
 from traitlets import (
     Dict, Any
 )
-from traitlets.config import catch_config_error
-from IPython.utils.warn import error
+from traitlets.config import catch_config_error, boolean_flag
 
 from jupyter_core.application import JupyterApp, base_aliases, base_flags, NoStart
 from jupyter_client.consoleapp import (
@@ -46,6 +45,11 @@ flags = dict(base_flags)
 frontend_flags = dict(app_flags)
 # update full dict with frontend flags:
 flags.update(frontend_flags)
+flags.update(boolean_flag(
+    'simple-prompt', 'ZMQTerminalInteractiveShell.simple_prompt',
+    "Force simple minimal prompt using `raw_input`",
+    "Use a rich interactive prompt with prompt_toolkit"
+))
 
 # copy flags from mixin
 aliases = dict(base_aliases)
@@ -120,8 +124,8 @@ class ZMQTerminalIPythonApp(JupyterApp, JupyterConsoleApp):
             if self.kernel_manager:
                 self.kernel_manager.interrupt_kernel()
             else:
-                print("", file=sys.stderr)
-                error("Cannot interrupt kernels we didn't start.\n")
+                print("ERROR: Cannot interrupt kernels we didn't start.",
+                      file = sys.stderr)
         else:
             # raise the KeyboardInterrupt if we aren't waiting for execution,
             # so that the interact loop advances, and prompt is redrawn, etc.
diff --git a/jupyter_console/completer.py b/jupyter_console/completer.py
index ba05d7c..281c76a 100644
--- a/jupyter_console/completer.py
+++ b/jupyter_console/completer.py
@@ -10,21 +10,9 @@ except ImportError:
     from Queue import Empty  # Py 2
 
 from traitlets.config import Configurable
-from IPython.core.completer import IPCompleter
-from ipython_genutils.py3compat import str_to_unicode, unicode_to_str, cast_bytes, cast_unicode
 from traitlets import Float
-import IPython.utils.rlineimpl as readline
 
-def _construct_readline_matches(code, cursor_pos, content):
-    cursor_start = content['cursor_start']
-    matches = [ code[:cursor_start] + m for m in content['matches'] ]
-    if content["cursor_end"] < cursor_pos:
-        extra = code[content["cursor_end"]: cursor_pos]
-        matches = [m + extra for m in matches]
-    matches = [ unicode_to_str(m) for m in matches ]
-    return matches
-
-class ZMQCompleter(IPCompleter):
+class ZMQCompleter(Configurable):
     """Client-side completion machinery.
 
     How it works: self.complete will be called multiple times, with
@@ -39,11 +27,6 @@ class ZMQCompleter(IPCompleter):
         self.shell = shell
         self.client =  client
         self.matches = []
-        # don't do any splitting client-side,
-        # rely on the kernel for that
-        self.splitter.delims = '\r\n'
-        if hasattr(self.readline, 'set_completer_delims'):
-            self.readline.set_completer_delims('\r\n')
     
     def complete_request(self, code, cursor_pos):
         # send completion request to kernel
@@ -59,24 +42,4 @@ class ZMQCompleter(IPCompleter):
 
         return {'matches': [], 'cursor_start': 0, 'cursor_end': 0,
                 'metadata': {}, 'status': 'ok'}
-    
-    def rlcomplete(self, text, state):
-        if state == 0:
-            line = str_to_unicode(readline.get_line_buffer())
-            byte_cursor_pos = readline.get_endidx()
-            # get_endidx is a byte offset
-            # account for multi-byte characters to get correct cursor_pos
-            bytes_before_cursor = cast_bytes(line)[:byte_cursor_pos]
-            cursor_pos = len(cast_unicode(bytes_before_cursor))
-            try:
-                content = self.complete_request(line, cursor_pos)
-                self.matches = _construct_readline_matches(line, cursor_pos, content)
-            except Empty:
-                #print('WARNING: Kernel timeout on tab completion.')
-                pass
-        
-        try:
-            return self.matches[state]
-        except IndexError:
-            return None
 
diff --git a/jupyter_console/ptshell.py b/jupyter_console/ptshell.py
index 45e7f86..04edd52 100644
--- a/jupyter_console/ptshell.py
+++ b/jupyter_console/ptshell.py
@@ -33,7 +33,7 @@ from prompt_toolkit.completion import Completer, Completion
 from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
 from prompt_toolkit.filters import HasFocus, HasSelection, ViInsertMode, EmacsInsertMode
 from prompt_toolkit.history import InMemoryHistory
-from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop
+from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_output
 from prompt_toolkit.interface import CommandLineInterface
 from prompt_toolkit.key_binding.manager import KeyBindingManager
 from prompt_toolkit.key_binding.vi_state import InputMode
@@ -43,7 +43,8 @@ from prompt_toolkit.layout.lexers import PygmentsLexer
 from prompt_toolkit.styles import PygmentsStyle
 
 from pygments.styles import get_style_by_name
-from pygments.lexers import LEXERS, find_lexer_class
+from pygments.lexers import get_lexer_by_name
+from pygments.util import ClassNotFound
 from pygments.token import Token
 
 def ask_yes_no(prompt, default=None, interrupt=None):
@@ -87,13 +88,12 @@ def get_pygments_lexer(name):
         from IPython.lib.lexers import IPython3Lexer
         return IPython3Lexer
     else:
-        for module_name, cls_name, aliases, _, _ in LEXERS.values():
-            if name in aliases:
-                return find_lexer_class(cls_name)
-
-        warn("No lexer found for language %r. Treating as plain text." % name)
-        from pygments.lexers.special import TextLexer
-        return TextLexer
+        try:
+            return get_lexer_by_name(name).__class__
+        except ClassNotFound:
+            warn("No lexer found for language %r. Treating as plain text." % name)
+            from pygments.lexers.special import TextLexer
+            return TextLexer
 
 
 class JupyterPTCompleter(Completer):
@@ -135,6 +135,13 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
         help="Override highlighting format for specific tokens"
     )
 
+    true_color = Bool(False, config=True,
+        help=("Use 24bit colors instead of 256 colors in prompt highlighting. "
+              "If your terminal supports true color, the following command "
+              "should print 'TRUECOLOR' in orange: "
+              "printf \"\\x1b[38;2;255;100;0mTRUECOLOR\\x1b[0m\\n\"")
+    )
+
     history_load_length = Integer(1000, config=True,
         help="How many history items to load into memory"
     )
@@ -229,6 +236,14 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
         """
     )
 
+
+    confirm_exit = Bool(True, config=True,
+        help="""Set to display confirmation dialog on exit.
+        You can always use 'exit' or 'quit', to force a
+        direct exit without any confirmation.
+        """
+    )
+
     manager = Instance('jupyter_client.KernelManager', allow_none=True)
     client = Instance('jupyter_client.KernelClient', allow_none=True)
     def _client_changed(self, name, old, new):
@@ -238,6 +253,10 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
     def _banner1_default(self):
         return "Jupyter Console {version}\n".format(version=__version__)
 
+    simple_prompt = Bool(False,
+         help="""Use simple fallback prompt. Features may be limited."""
+    ).tag(config=True)
+
     def __init__(self, **kwargs):
         # This is where traits with a config_key argument are updated
         # from the values on config.
@@ -313,7 +332,7 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
                          kernel_banner=self.kernel_info.get('banner', '')))
 
     def init_prompt_toolkit_cli(self):
-        if 'JUPYTER_CONSOLE_TEST' in os.environ:
+        if self.simple_prompt or ('JUPYTER_CONSOLE_TEST' in os.environ):
             # Simple restricted interface for tests so we can find prompts with
             # pexpect. Multi-line input not supported.
             def prompt():
@@ -401,7 +420,10 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
         )
 
         self._eventloop = create_eventloop()
-        self.pt_cli = CommandLineInterface(app, eventloop=self._eventloop)
+        self.pt_cli = CommandLineInterface(app,
+                            eventloop=self._eventloop,
+                            output=create_output(true_color=self.true_color),
+        )
 
     def prompt_for_code(self):
         document = self.pt_cli.run(pre_run=self.pre_prompt,
@@ -423,8 +445,12 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
             except SyntaxError:
                 return False, ""
         else:
-            more = (code.splitlines()[-1] != "")
-            return more, ""
+            lines = code.splitlines()
+            if len(lines):
+                more = (lines[-1] != "")
+                return more, ""
+            else:
+                return False, ""
 
     def ask_exit(self):
         self.keep_running = False
@@ -447,7 +473,8 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
             try:
                 code = self.prompt_for_code()
             except EOFError:
-                if ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
+                if (not self.confirm_exit) \
+                    or ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
                     self.ask_exit()
 
             else:
@@ -465,7 +492,8 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
             except KeyboardInterrupt:
                 print("\nKeyboardInterrupt escaped interact()\n")
 
-        self._eventloop.close()
+        if self._eventloop:
+            self._eventloop.close()
         if self.keepkernel and not self.own_kernel:
             print('keeping kernel alive')
         elif self.keepkernel and self.own_kernel :
@@ -665,6 +693,10 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
                     if 'text/plain' not in format_dict:
                         continue
 
+                    # prompt_toolkit writes the prompt at a slightly lower level,
+                    # so flush streams first to ensure correct ordering.
+                    sys.stdout.flush()
+                    sys.stderr.flush()
                     self.print_out_prompt()
                     text_repr = format_dict['text/plain']
                     if '\n' in text_repr:
@@ -687,7 +719,7 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
                     if not self.from_here(sub_msg):
                         sys.stdout.write(self.other_output_prefix)
                     sys.stdout.write('In [{}]: '.format(content['execution_count']))
-                    sys.stdout.write(content['code'])
+                    sys.stdout.write(content['code']+'\n')
 
                 elif msg_type == 'clear_output':
                     if sub_msg["content"]["wait"]:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/jupyter-console.git



More information about the Python-modules-commits mailing list