MCPcopy Index your code
hub / github.com/ipython/ipython / pop

Method pop

IPython/core/formatters.py:573–612  ·  view source on GitHub ↗

Pop a formatter for the given type. Parameters ---------- typ : type or '__module__.__name__' string for a type default : object value to be returned if no formatter is registered for typ. Returns ------- obj : object

(self, typ, default=_raise_key_error)

Source from the content-addressed store, hash-verified

571 return oldfunc
572
573 def pop(self, typ, default=_raise_key_error):
574 """Pop a formatter for the given type.
575
576 Parameters
577 ----------
578 typ : type or '__module__.__name__' string for a type
579 default : object
580 value to be returned if no formatter is registered for typ.
581
582 Returns
583 -------
584 obj : object
585 The last registered object for the type.
586
587 Raises
588 ------
589 KeyError if the type is not registered and default is not specified.
590 """
591
592 if isinstance(typ, str):
593 typ_key = tuple(typ.rsplit('.',1))
594 if typ_key not in self.deferred_printers:
595 # We may have it cached in the type map. We will have to
596 # iterate over all of the types to check.
597 for cls in self.type_printers:
598 if _mod_name_key(cls) == typ_key:
599 old = self.type_printers.pop(cls)
600 break
601 else:
602 old = default
603 else:
604 old = self.deferred_printers.pop(typ_key)
605 else:
606 if typ in self.type_printers:
607 old = self.type_printers.pop(typ)
608 else:
609 old = self.deferred_printers.pop(_mod_name_key(typ), default)
610 if old is _raise_key_error:
611 raise KeyError("No registered value for {0!r}".format(typ))
612 return old
613
614 def _in_deferred_types(self, cls):
615 """

Callers 15

__exit__Method · 0.80
token_at_cursorFunction · 0.80
cmdloopMethod · 0.80
_elide_pointFunction · 0.80
__init__Method · 0.80
__call__Method · 0.80
embedFunction · 0.80
get_stackMethod · 0.80
startMethod · 0.80
profileapp.pyFile · 0.80
pushMethod · 0.80
drop_by_idMethod · 0.80

Calls 2

_mod_name_keyFunction · 0.85
formatMethod · 0.45

Tested by 15

tearDownMethod · 0.64
setupMethod · 0.64
test_popFunction · 0.64
test_pop_stringFunction · 0.64
test_get_home_dir_8Function · 0.64
test_get_xdg_dir_0Function · 0.64
test_get_xdg_dir_1Function · 0.64
test_get_xdg_dir_2Function · 0.64
test_get_xdg_dir_3Function · 0.64
test_not_writable_ipdirFunction · 0.64
test_store_restoreFunction · 0.64
test_pasteMethod · 0.64