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

Function record_magic

IPython/core/magic.py:112–132  ·  view source on GitHub ↗

Utility function to store a function as a magic of a specific kind. Parameters ---------- dct : dict A dictionary with 'line' and 'cell' subdicts. magic_kind : str Kind of magic to be stored. magic_name : str Key to store the magic as. func : function

(dct, magic_kind, magic_name, func)

Source from the content-addressed store, hash-verified

110
111
112def record_magic(dct, magic_kind, magic_name, func):
113 """Utility function to store a function as a magic of a specific kind.
114
115 Parameters
116 ----------
117 dct : dict
118 A dictionary with 'line' and 'cell' subdicts.
119
120 magic_kind : str
121 Kind of magic to be stored.
122
123 magic_name : str
124 Key to store the magic as.
125
126 func : function
127 Callable object to store.
128 """
129 if magic_kind == 'line_cell':
130 dct['line'][magic_name] = dct['cell'][magic_name] = func
131 else:
132 dct[magic_kind][magic_name] = func
133
134
135def validate_type(magic_kind):

Callers 4

magic_decoFunction · 0.85
markFunction · 0.85
register_functionMethod · 0.85
register_aliasMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected