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)
| 110 | |
| 111 | |
| 112 | def 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 | |
| 135 | def validate_type(magic_kind): |
no outgoing calls
no test coverage detected