##// END OF EJS Templates
Merge pull request #1008 from minrk/excepthook...
Merge pull request #1008 from minrk/excepthook Use a much more restrained crash handler by default. Now the excepthook shows a regular traceback, with a brief message about reporting bugs and how to enable to the big crash handler. Our previous, extremely verbose crash handler can still be activated via `%config Application.verbose_crash=True`, so we can debug real crashes or ask users for extra detail easily. Small fixes along the way: * current Application added to configurables list, for use in %config. * email addresses in full crash reports changed to ipython-dev, so they don't go straight to individual users. Should close #695, and ameliorate #833 (doesn't fix the bug, but the message is more sensible).

File last commit:

r4862:afbc4511
r5348:493f6d4b merge
Show More
payloadpage.py
96 lines | 2.8 KiB | text/x-python | PythonLexer
Brian Granger
Paging using payloads now works.
r2830 # encoding: utf-8
"""
A payload based version of page.
Authors:
* Brian Granger
* Fernando Perez
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2010 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Fernando Perez
Provide html support for page() in the payload version....
r3011 # Third-party
try:
from docutils.core import publish_string
except ImportError:
# html paging won't be available, but we don't raise any errors. It's a
# purely optional feature.
pass
# Our own
Brian Granger
Paging using payloads now works.
r2830 from IPython.core.interactiveshell import InteractiveShell
#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------
Fernando Perez
Provide html support for page() in the payload version....
r3011 def page(strng, start=0, screen_lines=0, pager_cmd=None,
html=None, auto_html=False):
Brian Granger
Paging using payloads now works.
r2830 """Print a string, piping through a pager.
This version ignores the screen_lines and pager_cmd arguments and uses
IPython's payload system instead.
Fernando Perez
Provide html support for page() in the payload version....
r3011
Parameters
----------
strng : str
Text to page.
start : int
Starting line at which to place the display.
html : str, optional
If given, an html string to send as well.
auto_html : bool, optional
If true, the input string is assumed to be valid reStructuredText and is
converted to HTML with docutils. Note that if docutils is not found,
this option is silently ignored.
Note
----
Only one of the ``html`` and ``auto_html`` options can be given, not
both.
Brian Granger
Paging using payloads now works.
r2830 """
# Some routines may auto-compute start offsets incorrectly and pass a
# negative value. Offset to 0 for robustness.
start = max(0, start)
shell = InteractiveShell.instance()
Fernando Perez
Provide html support for page() in the payload version....
r3011
if auto_html:
try:
# These defaults ensure user configuration variables for docutils
# are not loaded, only our config is used here.
defaults = {'file_insertion_enabled': 0,
'raw_enabled': 0,
'_disable_config': 1}
html = publish_string(strng, writer_name='html',
settings_overrides=defaults)
except:
pass
Brian Granger
Paging using payloads now works.
r2830 payload = dict(
source='IPython.zmq.page.page',
Fernando Perez
Provide html support for page() in the payload version....
r3011 text=strng,
html=html,
Brian Granger
Paging using payloads now works.
r2830 start_line_number=start
Fernando Perez
Provide html support for page() in the payload version....
r3011 )
Brian Granger
Paging using payloads now works.
r2830 shell.payload_manager.write_payload(payload)
Fernando Perez
Provide html support for page() in the payload version....
r3011
Brian Granger
Paging using payloads now works.
r2830 def install_payload_page():
"""Install this version of page as IPython.core.page.page."""
from IPython.core import page as corepage
corepage.page = page