turn magics dict into jsonable dict of the same structure replaces object instances with their class names as strings
(self)
| 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() |