
    ^hv2                         S r SSKJr  SSKrSSKrSSKr/ SQrS r " S S5      r\" 5       r	S\	4SS.S	 jjr
S
 rSSSSSSSS.S jrS r " S S\5      rSS jrg)zGTop-level display functions for displaying object in different formats.    )b2a_hexN)displayclear_outputpublish_display_dataupdate_displayDisplayHandlec                     [        U[        5      (       a  [        U [        5      (       d  U$ UR                  5        H"  u  p#[        U R	                  U5      U5      X'   M$     U $ )z_Like update, but merges sub-dicts instead of clobbering at the top level.

Updates d1 in-place
)
isinstancedictitems_mergeget)d1d2keyvalues       X/home/james-whalen/.local/lib/python3.13/site-packages/IPython/core/display_functions.pyr   r      sO     b$z"d';';	hhj
e, !I    c                       \ rS rSrS rSrg)	_Sentinel%   c                     g)Nz<deprecated> selfs    r   __repr___Sentinel.__repr__&   s    r   r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r   %   s    r   r   )	transientc                    SSK Jn  U[        La  [        R                  " S[
        SS9  UR                  5       R                  nU(       a  X4S'   UR                  " S	U US.UD6  g)
a  Publish data and metadata to all frontends.

See the ``display_data`` message in the messaging documentation for
more details about this message type.

Keys of data and metadata can be any mime-type.

Parameters
----------
data : dict
    A dictionary having keys that are valid MIME types (like
    'text/plain' or 'image/svg+xml') and values that are the data for
    that MIME type. The data itself must be a JSON'able data
    structure. Minimally all data should have the 'text/plain' data,
    which can be displayed by all frontends. If more than the plain
    text is given, it is up to the frontend to decide which
    representation to use.
metadata : dict
    A dictionary for metadata related to the data. This can contain
    arbitrary key, value pairs that frontends can use to interpret
    the data. mime-type keys matching those in data can be used
    to specify metadata about particular representations.
source : str, deprecated
    Unused.
transient : dict, keyword-only
    A dictionary of transient data, such as display_id.
r   InteractiveShellzThe `source` parameter emit a  deprecation warning since IPython 8.0, it had no effects for a long time and will  be removed in future versions.   )
stacklevelr#   datametadataNr   )	IPython.core.interactiveshellr&   	_sentinelwarningswarnDeprecationWarninginstancedisplay_pubpublish)r*   r+   sourcer#   kwargsr&   r2   s          r   r   r   -   sn    < ?Y. 	
 #++-99K
 '{  r   c                  ^    [        [        R                  " S5      5      R                  S5      $ )z*Generate a new random text id with urandom   ascii)r   osurandomdecoder   r   r   _new_idr<   d   s     2::b>"))'22r   F)includeexcluder+   r#   
display_idrawclearc                 X   SSK Jn	  U	R                  5       (       d	  [        U6   gUc  0 nUc  0 nU(       a  USL a
  [	        5       nXCS'   UR                  S5      (       a  SU;  a  [        S5      eU(       a  X8S'   U(       d  U(       a  0 /nSnU(       d$  U	R                  5       R                  R                  n
U(       a	  [        SS	9  U HJ  nU(       a  [        SXS
.UD6  M  W
" XUS9u  pU(       d  M+  U(       a  [        X5        [        SXS
.UD6  ML     U(       a  [        U5      $ g)aJ  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.

In terminal IPython this will be similar to using :func:`print`, for use in richer
frontends see Jupyter notebook examples with rich display logic.

Parameters
----------
*objs : object
    The Python objects to display.
raw : bool, optional
    Are the objects to be displayed already mimetype-keyed dicts of raw display data,
    or Python objects that need to be formatted before display? [default: False]
include : list, tuple or set, 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, tuple or set, optional
    A list of format type strings (MIME types) to exclude in the format
    data dict. If this is set all format types will be computed,
    except for those included in this argument.
metadata : dict, optional
    A dictionary of metadata to associate with the output.
    mime-type keys in this dictionary will be associated with the individual
    representation formats, if they exist.
transient : dict, optional
    A dictionary of transient data to associate with the output.
    Data in this dict should not be persisted to files (e.g. notebooks).
display_id : str, bool optional
    Set an id for the display.
    This id can be used for updating this display area later via update_display.
    If given as `True`, generate a new `display_id`
clear : bool, optional
    Should the output area be cleared before displaying anything? If True,
    this will wait for additional output before clearing. [default: False]
**kwargs : additional keyword-args, optional
    Additional keyword-arguments are passed through to the display publisher.

Returns
-------
handle: DisplayHandle
    Returns a handle on updatable displays for use with :func:`update_display`,
    if `display_id` is given. Returns :any:`None` if no `display_id` is given
    (default).

Examples
--------
>>> class Json(object):
...     def __init__(self, json):
...         self.json = json
...     def _repr_pretty_(self, pp, cycle):
...         import json
...         pp.text(json.dumps(self.json, indent=2))
...     def __repr__(self):
...         return str(self.json)
...

>>> d = Json({1:2, 3: {4:5}})

>>> print(d)
{1: 2, 3: {4: 5}}

>>> display(d)
{
  "1": 2,
  "3": {
    "4": 5
  }
}

>>> def int_formatter(integer, pp, cycle):
...     pp.text('I'*integer)

>>> plain = get_ipython().display_formatter.formatters['text/plain']
>>> plain.for_type(int, int_formatter)
<function _repr_pprint at 0x...>
>>> display(7-5)
II

>>> del plain.type_printers[int]
>>> display(7-5)
2

See Also
--------
:func:`update_display`

Notes
-----
In Python, objects can declare their textual representation using the
`__repr__` method. IPython expands on this idea and allows objects to declare
other, rich representations including:

  - HTML
  - JSON
  - PNG
  - JPEG
  - SVG
  - LaTeX

A single object can declare some or all of these representations; all are
handled by IPython's display system.

The main idea of the first approach is that you have to implement special
display methods when you define your class, one for each representation you
want to use. Here is a list of the names of the special methods and the
values they must return:

  - `_repr_html_`: return raw HTML as a string, or a tuple (see below).
  - `_repr_json_`: return a JSONable dict, or a tuple (see below).
  - `_repr_jpeg_`: return raw JPEG data, or a tuple (see below).
  - `_repr_png_`: return raw PNG data, or a tuple (see below).
  - `_repr_svg_`: return raw SVG data as a string, or a tuple (see below).
  - `_repr_latex_`: return LaTeX commands in a string surrounded by "$",
                    or a tuple (see below).
  - `_repr_mimebundle_`: return a full mimebundle containing the mapping
                         from all mimetypes to data.
                         Use this for any mime-type not listed above.

The above functions may also return the object's metadata alonside the
data.  If the metadata is available, the functions will return a tuple
containing the data and metadata, in that order.  If there is no metadata
available, then the functions will return the data only.

When you are directly writing your own classes, you can adapt them for
display in IPython by following the above approach. But in practice, you
often need to work with existing classes that you can't easily modify.

You can refer to the documentation on integrating with the display system in
order to register custom formatters for already existing types
(:ref:`integrating_rich_display`).

.. versionadded:: 5.4 display available without import
.. versionadded:: 6.1 display available without import

Since IPython 5.4 and 6.1 :func:`display` is automatically made available to
the user without import. If you are using display in a document that might
be used in a pure python context or with older version of IPython, use the
following import at the top of your file::

    from IPython.display import display

r   r%   NTr?   updatez&display_id required for update_displayr#   )waitr)   )r=   r>   r   )r,   r&   initializedprintr<   r   	TypeErrorr1   display_formatterformatr   r   r   r   )r=   r>   r+   r#   r?   r@   rA   objsr5   r&   rI   objformat_dictmd_dicts                 r   r   r   i   s   x ?''))t	 J",,zz(I =@AA'{J t!**,>>EE$ GcGG#)##P Kw) NkNvN  Z(( r   c                *    SUS'   [        U 4SU0UD6  g)zUpdate an existing display by id

Parameters
----------
obj
    The object with which to update the display
display_id : keyword-only
    The id of the display to update

See Also
--------
:func:`display`
TrC   r?   N)r   )rK   r?   r5   s      r   r   r   7  s      F8C1J1&1r   c                   4    \ rS rSrSrS	S jrS rS rS rSr	g)
r   iI  zA handle on an updatable display

Call `.update(obj)` to display a new object.

Call `.display(obj`) to add a new instance of this display,
and update existing instances.

See Also
--------

    :func:`display`, :func:`update_display`

Nc                 *    Uc
  [        5       nXl        g N)r<   r?   )r   r?   s     r   __init__DisplayHandle.__init__X  s     J$r   c                 T    SU R                   R                  < SU R                  < S3$ )N<z display_id=>)	__class__r   r?   r   s    r   r   DisplayHandle.__repr__]  s    '+~~'>'>PPr   c                 4    [        U4SU R                  0UD6  g)zMake a new display with my id, updating existing instances.

Parameters
----------
obj
    object to display
**kwargs
    additional keyword arguments passed to display
r?   N)r   r?   r   rK   r5   s      r   r   DisplayHandle.display`  s     	::6:r   c                 4    [        U4SU R                  0UD6  g)zUpdate existing displays with my id

Parameters
----------
obj
    object to display
**kwargs
    additional keyword arguments passed to update_display
r?   N)r   r?   rZ   s      r   rC   DisplayHandle.updatel  s     	sAtA&Ar   )r?   rQ   )
r   r   r    r!   __doc__rR   r   r   rC   r"   r   r   r   r   r   I  s    %
Q
;
Br   r   c                 .   SSK Jn  UR                  5       (       a*  UR                  5       R                  R                  U 5        g[        SSS9  [        R                  R                  5         [        SSS9  [        R                  R                  5         g)zClear the output of the current cell receiving output.

Parameters
----------
wait : bool [default: false]
    Wait to clear the output until new output is available to replace it.r   r%   z[2K )endN)r,   r&   rE   r1   r2   r   rF   sysstdoutflushstderr)rD   r&   s     r   r   r   y  sg     ?##%%!!#//<<TBkr"

kr"

r   )F)r^   binasciir   r9   rb   r.   __all__r   r   r-   r   r<   r   r   objectr   r   r   r   r   <module>ri      s    M  	 
 
`
" 
 K	 	48<4n3 
J)\2$-BF -B`r   