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

Method _jsonable

IPython/core/magics/basic.py:46–64  ·  view source on GitHub ↗

turn magics dict into jsonable dict of the same structure replaces object instances with their class names as strings

(self)

Source from the content-addressed store, hash-verified

44 return self._lsmagic()
45
46 def _jsonable(self):
47 """turn magics dict into jsonable dict of the same structure
48
49 replaces object instances with their class names as strings
50 """
51 magic_dict = {}
52 mman = self.magics_manager
53 magics = mman.lsmagic()
54 for key, subdict in magics.items():
55 d = {}
56 magic_dict[key] = d
57 for name, obj in subdict.items():
58 try:
59 classname = obj.__self__.__class__.__name__
60 except AttributeError:
61 classname = 'Other'
62
63 d[name] = classname
64 return magic_dict
65
66 def _repr_json_(self):
67 return self._jsonable()

Callers 1

_repr_json_Method · 0.95

Calls 1

lsmagicMethod · 0.45

Tested by

no test coverage detected