Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
encoder = "text"
elif isinstance(scrap, (list, dict)):
encoder = "json"
else:
# This may be more complex in the future
encoder = "json"
# TODO: default to 'display' encoder when encoder is None and object is a display object type?
if display is None:
display = encoder == "display"
# Only store data that can be stored (purely display scraps can skip)
if encoder != "display":
data, metadata = _prepare_ipy_data_format(
name,
scrap_to_payload(encoder_registry.encode(Scrap(name, scrap, encoder))),
encoder,
)
ip_display(data, metadata=metadata, raw=True)
# Only display data that is marked for display
if display:
display_kwargs = {}
if isinstance(display, (list, tuple)):
display_kwargs = {"include": display}
elif isinstance(display, dict):
display_kwargs = display
raw_data, raw_metadata = IPython.core.formatters.format_display_data(
scrap, **display_kwargs
)
data, metadata = _prepare_ipy_display_format(name, raw_data, raw_metadata)
ip_display(data, metadata=metadata, raw=True)