MCPcopy Create free account
hub / github.com/ipython/ipython / __init__

Method __init__

IPython/core/display.py:584–631  ·  view source on GitHub ↗

Create a display object given raw data. When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should

(self, data=None, url=None, filename=None, metadata=None)

Source from the content-addressed store, hash-verified

582 metadata = None
583
584 def __init__(self, data=None, url=None, filename=None, metadata=None):
585 """Create a display object given raw data.
586
587 When this object is returned by an expression or passed to the
588 display function, it will result in the data being displayed
589 in the frontend. The MIME type of the data should match the
590 subclasses used, so the Png subclass should be used for 'image/png'
591 data. If the data is a URL, the data will first be downloaded
592 and then displayed. If
593
594 Parameters
595 ----------
596 data : unicode, str or bytes
597 The raw data or a URL or file to load the data from
598 url : unicode
599 A URL to download the data from.
600 filename : unicode
601 Path to a local file to load the data from.
602 metadata : dict
603 Dict of metadata associated to be the object when displayed
604 """
605 if isinstance(data, (Path, PurePath)):
606 data = str(data)
607
608 if data is not None and isinstance(data, str):
609 if data.startswith('http') and url is None:
610 url = data
611 filename = None
612 data = None
613 elif _safe_exists(data) and filename is None:
614 url = None
615 filename = data
616 data = None
617
618 self.url = url
619 self.filename = filename
620 # because of @data.setter methods in
621 # subclasses ensure url and filename are set
622 # before assigning to self.data
623 self.data = data
624
625 if metadata is not None:
626 self.metadata = metadata
627 elif self.metadata is None:
628 self.metadata = {}
629
630 self.reload()
631 self._check_data()
632
633 def __repr__(self):
634 if not self._show_mem_addr:

Callers

nothing calls this directly

Calls 3

reloadMethod · 0.95
_check_dataMethod · 0.95
_safe_existsFunction · 0.85

Tested by

no test coverage detected