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

Function record_magic

IPython/core/magic.py:125–147  ·  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: dict[str, dict[str, Any]],
    magic_kind: _MagicSpec,
    magic_name: str,
    func: Any,
)

Source from the content-addressed store, hash-verified

123
124
125def record_magic(
126 dct: dict[str, dict[str, Any]],
127 magic_kind: _MagicSpec,
128 magic_name: str,
129 func: Any,
130) -> None:
131 """Utility function to store a function as a magic of a specific kind.
132
133 Parameters
134 ----------
135 dct : dict
136 A dictionary with 'line' and 'cell' subdicts.
137 magic_kind : str
138 Kind of magic to be stored.
139 magic_name : str
140 Key to store the magic as.
141 func : function
142 Callable object to store.
143 """
144 if magic_kind == "line_cell":
145 dct["line"][magic_name] = dct["cell"][magic_name] = func
146 else:
147 dct[magic_kind][magic_name] = func
148
149
150def validate_type(magic_kind: str) -> None:

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…