##// END OF EJS Templates
re-enable log forwarding and iplogger
re-enable log forwarding and iplogger

File last commit:

r3878:43a27cb1
r3989:2e5a1161
Show More
display.py
130 lines | 3.7 KiB | text/x-python | PythonLexer
Brian Granger
Display system is fully working now....
r3278 # -*- coding: utf-8 -*-
"""Top-level display functions for displaying object in different formats.
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
# 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
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Main functions
#-----------------------------------------------------------------------------
Brian Granger
Final work on display system....
r3288 def display(*objs, **kwargs):
Brian Granger
Display system is fully working now....
r3278 """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.
Parameters
----------
Brian Granger
Final work on display system....
r3288 objs : tuple of objects
The Python objects to display.
Brian Granger
Display system is fully working now....
r3278 include : list or tuple, 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 or tuple, optional
A list of format type string (MIME types) to exclue in the format
data dict. If this is set all format types will be computed,
except for those included in this argument.
"""
Brian Granger
Final work on display system....
r3288 include = kwargs.get('include')
exclude = kwargs.get('exclude')
Brian Granger
Display system is fully working now....
r3278 from IPython.core.interactiveshell import InteractiveShell
Brian Granger
Addressing review comments....
r3286 inst = InteractiveShell.instance()
format = inst.display_formatter.format
publish = inst.display_pub.publish
Brian Granger
Display system is fully working now....
r3278
Brian Granger
Final work on display system....
r3288 for obj in objs:
format_dict = format(obj, include=include, exclude=exclude)
publish('IPython.core.display.display', format_dict)
Brian Granger
Display system is fully working now....
r3278
Brian Granger
Final work on display system....
r3288 def display_pretty(*objs):
Brian Granger
More improvements to the display system....
r3279 """Display the pretty (default) representation of an object.
Parameters
----------
Brian Granger
Final work on display system....
r3288 objs : tuple of objects
The Python objects to display.
Brian Granger
More improvements to the display system....
r3279 """
Brian Granger
Final work on display system....
r3288 display(*objs, include=['text/plain'])
Brian Granger
More improvements to the display system....
r3279
Brian Granger
Final work on display system....
r3288 def display_html(*objs):
Brian Granger
Display system is fully working now....
r3278 """Display the HTML representation of an object.
Parameters
----------
Brian Granger
Final work on display system....
r3288 objs : tuple of objects
The Python objects to display.
Brian Granger
Display system is fully working now....
r3278 """
Brian Granger
Final work on display system....
r3288 display(*objs, include=['text/plain','text/html'])
Brian Granger
Display system is fully working now....
r3278
Brian Granger
Final work on display system....
r3288 def display_svg(*objs):
Brian Granger
Display system is fully working now....
r3278 """Display the SVG representation of an object.
Parameters
----------
Brian Granger
Final work on display system....
r3288 objs : tuple of objects
The Python objects to display.
Brian Granger
Display system is fully working now....
r3278 """
Brian Granger
Final work on display system....
r3288 display(*objs, include=['text/plain','image/svg+xml'])
Brian Granger
Display system is fully working now....
r3278
Brian Granger
Final work on display system....
r3288 def display_png(*objs):
Brian Granger
Display system is fully working now....
r3278 """Display the PNG representation of an object.
Parameters
----------
Brian Granger
Final work on display system....
r3288 objs : tuple of objects
The Python objects to display.
Brian Granger
Display system is fully working now....
r3278 """
Brian Granger
Final work on display system....
r3288 display(*objs, include=['text/plain','image/png'])
Brian Granger
Display system is fully working now....
r3278
Brian Granger
Final work on display system....
r3288 def display_latex(*objs):
Brian Granger
Display system is fully working now....
r3278 """Display the LaTeX representation of an object.
Parameters
----------
Brian Granger
Final work on display system....
r3288 objs : tuple of objects
The Python objects to display.
Brian Granger
Display system is fully working now....
r3278 """
Brian Granger
Final work on display system....
r3288 display(*objs, include=['text/plain','text/latex'])
Brian Granger
Display system is fully working now....
r3278
Brian Granger
Final work on display system....
r3288 def display_json(*objs):
Brian Granger
Display system is fully working now....
r3278 """Display the JSON representation of an object.
Parameters
----------
Brian Granger
Final work on display system....
r3288 objs : tuple of objects
The Python objects to display.
Brian Granger
Display system is fully working now....
r3278 """
Brian Granger
Final work on display system....
r3288 display(*objs, include=['text/plain','application/json'])
Brian Granger
Display system is fully working now....
r3278
Brian Granger
Renaming the special methods of the formatters....
r3878 def display_javascript(*objs):
"""Display the Javascript representation of an object.
Brian Granger
Display system is fully working now....
r3278
Brian Granger
Renaming the special methods of the formatters....
r3878 Parameters
----------
objs : tuple of objects
The Python objects to display.
"""
display(*objs, include=['text/plain','application/javascript'])