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

Method _jsonable

IPython/core/magics/basic.py:50–68  ·  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

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

Callers 1

_repr_json_Method · 0.95

Calls 1

lsmagicMethod · 0.45

Tested by

no test coverage detected