##// END OF EJS Templates
Remove unnecessary metaclass and allow registration of magic classes....
Fernando Perez -
Show More
@@ -1999,12 +1999,10 b' class InteractiveShell(SingletonConfigurable):'
1999 1999 user_magics=mf.UserMagics(self))
2000 2000 self.configurables.append(self.magics_manager)
2001 2001
2002 all_m = [t(self) for t in [mf.BasicMagics, mf.CodeMagics,
2002 self.magics_manager.register(mf.BasicMagics, mf.CodeMagics,
2003 2003 mf.ConfigMagics, mf.NamespaceMagics, mf.ExecutionMagics,
2004 2004 mf.AutoMagics, mf.OSMagics, mf.LoggingMagics, mf.ExtensionsMagics,
2005 mf.PylabMagics, mf.DeprecatedMagics] ]
2006 self.all_m = all_m
2007 self.magics_manager.register(*all_m)
2005 mf.PylabMagics, mf.DeprecatedMagics)
2008 2006
2009 2007 # FIXME: Move the color initialization to the DisplayHook, which
2010 2008 # should be split into a prompt manager and displayhook. We probably
@@ -178,6 +178,10 b' class MagicsManager(Configurable):'
178 178 if not m.registered:
179 179 raise ValueError("Class of magics %r was constructed without "
180 180 "the @register_macics class decorator")
181 if type(m) is type:
182 # If we're given an uninstantiated class
183 m = m(self.shell)
184
181 185 for mtype in magic_types:
182 186 self.magics[mtype].update(m.magics[mtype])
183 187
@@ -228,10 +232,7 b' class Magics(object):'
228 232 # Non-configurable class attributes
229 233 magics = Dict
230 234
231 class __metaclass__(type):
232 def __new__(cls, name, bases, dct):
233 cls.registered = False
234 return type.__new__(cls, name, bases, dct)
235 registered = False
235 236
236 237 def __init__(self, shell):
237 238 if not(self.__class__.registered):
@@ -241,7 +242,8 b' class Magics(object):'
241 242 for mtype in magic_types:
242 243 tab = mtab[mtype]
243 244 for magic_name, meth_name in self.magics[mtype].iteritems():
244 tab[magic_name] = getattr(self, meth_name)
245 if isinstance(meth_name, basestring):
246 tab[magic_name] = getattr(self, meth_name)
245 247 self.magics.update(mtab)
246 248
247 249 def arg_err(self,func):
@@ -143,7 +143,6 b' class BasicMagics(Magics):'
143 143 magic_docs.append('%s%s:\n\t%s\n' %
144 144 (escape, fname, fndoc))
145 145
146
147 146 magic_docs = ''.join(magic_docs)
148 147
149 148 if mode == 'rest':
General Comments 0
You need to be logged in to leave comments. Login now