##// END OF EJS Templates
cleanup payloadpage (#14613)
M Bussonnier -
r29014:fdd09ec0 merge
parent child Browse files
Show More
@@ -1,51 +1,41
1 # encoding: utf-8
2 1 """A payload based version of page."""
3 2
4 3 # Copyright (c) IPython Development Team.
5 4 # Distributed under the terms of the Modified BSD License.
6 5
7 6 import warnings
8 7 from IPython.core.getipython import get_ipython
9 8
9 # see https://github.com/ipython/ipykernel/issues/1304
10 # this should be moved to ipykernel and removed in the long run.
11
10 12
11 13 def page(strng, start=0, screen_lines=0, pager_cmd=None):
12 14 """Print a string, piping through a pager.
13 15
14 16 This version ignores the screen_lines and pager_cmd arguments and uses
15 17 IPython's payload system instead.
16 18
17 19 Parameters
18 20 ----------
19 21 strng : str or mime-dict
20 22 Text to page, or a mime-type keyed dict of already formatted data.
21 23 start : int
22 24 Starting line at which to place the display.
23 25 """
24 26
25 27 # Some routines may auto-compute start offsets incorrectly and pass a
26 28 # negative value. Offset to 0 for robustness.
27 29 start = max(0, start)
28 30 shell = get_ipython()
29 31
30 32 if isinstance(strng, dict):
31 33 data = strng
32 34 else:
33 35 data = {'text/plain' : strng}
34 36 payload = dict(
35 37 source='page',
36 38 data=data,
37 39 start=start,
38 40 )
39 41 shell.payload_manager.write_payload(payload)
40
41
42 def install_payload_page():
43 """DEPRECATED, use show_in_pager hook
44
45 Install this version of page as IPython.core.page.page.
46 """
47 warnings.warn("""install_payload_page is deprecated.
48 Use `ip.set_hook('show_in_pager, page.as_hook(payloadpage.page))`
49 """)
50 from IPython.core import page as corepage
51 corepage.page = page
General Comments 0
You need to be logged in to leave comments. Login now