Hello community,
here is the log from the commit of package python3-jupyter_console for
openSUSE:Factory checked in at 2017-04-20 20:51:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python3-jupyter_console (Old)
and /work/SRC/openSUSE:Factory/.python3-jupyter_console.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-jupyter_console"
Thu Apr 20 20:51:08 2017 rev:9 rq:486616 version:5.1.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python3-jupyter_console/python3-jupyter_console-doc.changes
2016-08-05 18:16:15.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.python3-jupyter_console.new/python3-jupyter_console-doc.changes
2017-04-20 20:51:27.083710660 +0200
@@ -1,0 +2,16 @@
+Fri Apr 7 18:51:14 UTC 2017 - [email protected]
+
+- Update to 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.
+- Move tests to doc subpackage
+- Clean up doc building
+
+-------------------------------------------------------------------
python3-jupyter_console.changes: same change
Old:
----
jupyter_console-5.0.0.tar.gz
New:
----
jupyter_console-5.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python3-jupyter_console-doc.spec ++++++
--- /var/tmp/diff_new_pack.2IhZBS/_old 2017-04-20 20:51:27.775612823 +0200
+++ /var/tmp/diff_new_pack.2IhZBS/_new 2017-04-20 20:51:27.779612258 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python3-jupyter_console-doc
#
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,27 +16,34 @@
#
-%if 0%{?suse_version} && ( 0%{?suse_version} != 1315 && 0%{?suse_version} >
1110 )
-%define build_pdf 1
+%if 0%{?suse_version} && 0%{?suse_version} != 1315
+%bcond_without pdf
%else
-%define build_pdf 0
+%bcond_with pdf
%endif
+# Tests require an active console
+%bcond_with tests
+
Name: python3-jupyter_console-doc
-Version: 5.0.0
+Version: 5.1.0
Release: 0
Summary: Documentation for python3-jupyter_console
License: BSD-3-Clause
-Group: Documentation/Other
+Group: Development/Languages/Python
Url: http://jupyter.org
Source:
https://files.pythonhosted.org/packages/source/j/jupyter_console/jupyter_console-%{version}.tar.gz
+BuildRequires: fdupes
BuildRequires: python3-jupyter_console
# Documentation requirements
BuildRequires: python3-Sphinx
-%if %{build_pdf}
+%if %{with pdf}
BuildRequires: python3-Sphinx-latex
%endif
-Recommends: python3-jupyter_console = %{version}
+%if %{with tests}
+# Test requirements
+BuildRequires: python3-nose
+%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
Provides: %{name}-html = %{version}
@@ -51,24 +58,33 @@
%setup -q -n jupyter_console-%{version}
%build
-# Not Needed
-
-%install
# Build the documentation
pushd docs
-%if %{build_pdf}
-PYTHONPATH=%{buildroot}%{python3_sitelib} make latexpdf
+%if %{with pdf}
+make latexpdf
%endif
-PYTHONPATH=%{buildroot}%{python3_sitelib} make html
+make html
rm -rf _build/html/.buildinfo
popd
+%install
+mkdir -p %{buildroot}%{_docdir}/python3-jupyter_console
+
+%if %{with pdf}
+cp docs/_build/latex/*.pdf %{buildroot}%{_docdir}/python3-jupyter_console/
+%endif
+
+cp -r docs/_build/html %{buildroot}%{_docdir}/python3-jupyter_console/
+%fdupes %{buildroot}%{_docdir}/python3-jupyter_console/
+
+%if %{with tests}
+%check
+nosetests jupyter_console
+%endif
+
%files
%defattr(-,root,root,-)
%doc COPYING.md
-%doc docs/_build/html/
-%if %{build_pdf}
-%doc docs/_build/latex/*.pdf
-%endif
+%{_docdir}/python3-jupyter_console/
%changelog
++++++ python3-jupyter_console.spec ++++++
--- /var/tmp/diff_new_pack.2IhZBS/_old 2017-04-20 20:51:27.803608865 +0200
+++ /var/tmp/diff_new_pack.2IhZBS/_new 2017-04-20 20:51:27.807608299 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python3-jupyter_console
#
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
Name: python3-jupyter_console
-Version: 5.0.0
+Version: 5.1.0
Release: 0
Summary: Jupyter terminal console
License: BSD-3-Clause
@@ -25,29 +25,13 @@
Url: http://jupyter.org
Source:
https://files.pythonhosted.org/packages/source/j/jupyter_console/jupyter_console-%{version}.tar.gz
BuildRequires: python3-devel
-BuildRequires: python3-Pillow
-BuildRequires: python3-Pygments
-BuildRequires: python3-jupyter_core
BuildRequires: python3-jupyter_client
BuildRequires: python3-jupyter_ipykernel
BuildRequires: python3-jupyter_ipython
-BuildRequires: python3-prompt_toolkit
-BuildRequires: python3-pyzmq
BuildRequires: python3-setuptools
-BuildRequires: python3-traitlets
-# Test requirements
-BuildRequires: python3-ipython_genutils
-BuildRequires: python3-nose
-BuildRequires: python3-pexpect
-Requires: python3-Pygments
-Requires: python3-jupyter_core
Requires: python3-jupyter_client
Requires: python3-jupyter_ipykernel
Requires: python3-jupyter_ipython
-Requires: python3-prompt_toolkit
-Requires: python3-pyzmq
-Requires: python3-traitlets
-Recommends: python3-Pillow
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -66,14 +50,12 @@
%install
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
-mv %{buildroot}%{_bindir}/jupyter-console
%{buildroot}%{_bindir}/jupyter3-console
-ln -s -f %{_bindir}/jupyter3-console
%{buildroot}%{_bindir}/jupyter-console-%{py3_ver}
-
# Prepare for update-alternatives usage
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
+mv %{buildroot}%{_bindir}/jupyter-console
%{buildroot}%{_bindir}/jupyter-console-%{py3_ver}
ln -s -f %{_sysconfdir}/alternatives/jupyter-console
%{buildroot}%{_bindir}/jupyter-console
-# create a dummy target for /etc/alternatives/jupyter-console
-touch %{buildroot}%{_sysconfdir}/alternatives/jupyter-console
+
+ln -s %{_bindir}/jupyter-console-%{py3_ver}
%{buildroot}%{_bindir}/jupyter3-console
%post
%_sbindir/update-alternatives \
@@ -84,10 +66,6 @@
%_sbindir/update-alternatives --remove jupyter-console
%{_bindir}/jupyter-console-%{py3_ver}
fi
-# Tests require an interactive console
-# %check
-# nosetests -s -e ZMQTerminalInteractiveShellTestCase jupyter_console
-
%files
%defattr(-,root,root,-)
%doc CONTRIBUTING.md COPYING.md README.md
++++++ jupyter_console-5.0.0.tar.gz -> jupyter_console-5.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/PKG-INFO
new/jupyter_console-5.1.0/PKG-INFO
--- old/jupyter_console-5.0.0/PKG-INFO 2016-07-05 18:16:44.000000000 +0200
+++ new/jupyter_console-5.1.0/PKG-INFO 2017-02-03 16:43:54.000000000 +0100
@@ -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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/README.md
new/jupyter_console-5.1.0/README.md
--- old/jupyter_console-5.0.0/README.md 2016-03-10 19:38:25.000000000 +0100
+++ new/jupyter_console-5.1.0/README.md 2016-10-22 18:24:16.000000000 +0200
@@ -1,14 +1,18 @@
# Jupyter Console
[](https://travis-ci.org/jupyter/jupyter_console)
-[](http://jupyter-console.readthedocs.org/en/latest/?badge=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 @@
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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/docs/changelog.rst
new/jupyter_console-5.1.0/docs/changelog.rst
--- old/jupyter_console-5.0.0/docs/changelog.rst 2016-07-05
18:04:11.000000000 +0200
+++ new/jupyter_console-5.1.0/docs/changelog.rst 2017-02-03
16:36:12.000000000 +0100
@@ -3,9 +3,25 @@
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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/docs/conf.py
new/jupyter_console-5.1.0/docs/conf.py
--- old/jupyter_console-5.0.0/docs/conf.py 2016-03-10 19:38:25.000000000
+0100
+++ new/jupyter_console-5.1.0/docs/conf.py 2016-10-22 18:24:16.000000000
+0200
@@ -20,7 +20,13 @@
# 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 @@
# 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 @@
# 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/docs/environment.yml
new/jupyter_console-5.1.0/docs/environment.yml
--- old/jupyter_console-5.0.0/docs/environment.yml 1970-01-01
01:00:00.000000000 +0100
+++ new/jupyter_console-5.1.0/docs/environment.yml 2016-09-17
10:09:23.000000000 +0200
@@ -0,0 +1,11 @@
+name: jupyterconsole
+channels:
+ - conda-forge
+ - conda
+dependencies:
+ - python=3
+ - ipython
+ - jupyter_core
+ - jupyter_client
+ - sphinx
+ - sphinx_rtd_theme
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/docs/index.rst
new/jupyter_console-5.1.0/docs/index.rst
--- old/jupyter_console-5.0.0/docs/index.rst 2016-06-07 23:34:39.000000000
+0200
+++ new/jupyter_console-5.1.0/docs/index.rst 2016-09-17 10:09:23.000000000
+0200
@@ -6,6 +6,10 @@
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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/docs/release.rst
new/jupyter_console-5.1.0/docs/release.rst
--- old/jupyter_console-5.0.0/docs/release.rst 2016-06-07 23:36:55.000000000
+0200
+++ new/jupyter_console-5.1.0/docs/release.rst 2017-02-03 16:38:00.000000000
+0100
@@ -6,12 +6,6 @@
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 @@
.. 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/docs/requirements.txt
new/jupyter_console-5.1.0/docs/requirements.txt
--- old/jupyter_console-5.0.0/docs/requirements.txt 2016-03-10
19:38:25.000000000 +0100
+++ new/jupyter_console-5.1.0/docs/requirements.txt 2016-09-17
10:09:23.000000000 +0200
@@ -1,2 +1,5 @@
--e git://github.com/ipython/ipython#egg=ipython
--e .
+ipython
+-e ../.
+jupyter_core
+jupyter_client
+sphinx
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/jupyter_console/_version.py
new/jupyter_console-5.1.0/jupyter_console/_version.py
--- old/jupyter_console-5.0.0/jupyter_console/_version.py 2016-07-05
18:15:46.000000000 +0200
+++ new/jupyter_console-5.1.0/jupyter_console/_version.py 2017-02-03
16:40:10.000000000 +0100
@@ -5,6 +5,6 @@
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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/jupyter_console/app.py
new/jupyter_console-5.1.0/jupyter_console/app.py
--- old/jupyter_console-5.0.0/jupyter_console/app.py 2016-06-06
20:43:11.000000000 +0200
+++ new/jupyter_console-5.1.0/jupyter_console/app.py 2017-02-03
16:38:05.000000000 +0100
@@ -16,8 +16,7 @@
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 @@
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 @@
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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/jupyter_console/completer.py
new/jupyter_console-5.1.0/jupyter_console/completer.py
--- old/jupyter_console-5.0.0/jupyter_console/completer.py 2016-06-06
20:43:11.000000000 +0200
+++ new/jupyter_console-5.1.0/jupyter_console/completer.py 2016-10-22
18:26:40.000000000 +0200
@@ -10,21 +10,9 @@
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 @@
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 @@
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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jupyter_console-5.0.0/jupyter_console/ptshell.py
new/jupyter_console-5.1.0/jupyter_console/ptshell.py
--- old/jupyter_console-5.0.0/jupyter_console/ptshell.py 2016-07-05
18:01:09.000000000 +0200
+++ new/jupyter_console-5.1.0/jupyter_console/ptshell.py 2017-02-03
16:38:05.000000000 +0100
@@ -33,7 +33,7 @@
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.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 @@
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 @@
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 @@
"""
)
+
+ 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 @@
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 @@
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 @@
)
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 @@
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 @@
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 @@
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 @@
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 @@
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"]: