Show More
@@ -232,19 +232,27 b' class Magics(object):' | |||
|
232 | 232 | magics = None |
|
233 | 233 | # Flag to check that the class decorator was properly applied |
|
234 | 234 | registered = False |
|
235 | # Instance of IPython shell | |
|
236 | shell = None | |
|
235 | 237 | |
|
236 | 238 | def __init__(self, shell): |
|
237 | 239 | if not(self.__class__.registered): |
|
238 |
raise ValueError(' |
|
|
240 | raise ValueError('Magics subclass without registration - ' | |
|
241 | 'did you forget to apply @register_magics?') | |
|
239 | 242 | self.shell = shell |
|
240 | 243 | self.options_table = {} |
|
241 | mtab = dict(line={}, cell={}) | |
|
244 | # The method decorators are run when the instance doesn't exist yet, so | |
|
245 | # they can only record the names of the methods they are supposed to | |
|
246 | # grab. Only now, that the instance exists, can we create the proper | |
|
247 | # mapping to bound methods. So we read the info off the original names | |
|
248 | # table and replace each method name by the actual bound method. | |
|
242 | 249 | for mtype in magic_types: |
|
243 |
tab = |
|
|
244 | for magic_name, meth_name in self.magics[mtype].iteritems(): | |
|
250 | tab = self.magics[mtype] | |
|
251 | # must explicitly use keys, as we're mutating this puppy | |
|
252 | for magic_name in tab.keys(): | |
|
253 | meth_name = tab[magic_name] | |
|
245 | 254 | if isinstance(meth_name, basestring): |
|
246 | 255 | tab[magic_name] = getattr(self, meth_name) |
|
247 | self.magics.update(mtab) | |
|
248 | 256 | |
|
249 | 257 | def arg_err(self,func): |
|
250 | 258 | """Print docstring if incorrect arguments were passed""" |
General Comments 0
You need to be logged in to leave comments.
Login now