abstract method loading

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2011-11-08 22:32:03 -05:00
parent f9482725d7
commit 1ea5d18fa5
1 changed files with 19 additions and 8 deletions

View File

@ -156,14 +156,15 @@ class Application(object):
'method.git', 'method.git',
) )
for name in names: for name in names:
exec("import %s" % name) self.load_pmacs_methods(name)
mod = eval(name) #exec("import %s" % name)
for mname in dir(mod): #mod = eval(name)
if mname.startswith('_'): #for mname in dir(mod):
continue # if mname.startswith('_'):
cls = eval("%s.%s" % (name, mname)) # continue
if hasattr(cls, '_is_method') and cls._is_method: # cls = eval("%s.%s" % (name, mname))
self.methods[cls._name()] = cls() # if hasattr(cls, '_is_method') and cls._is_method:
# self.methods[cls._name()] = cls()
# ok, now let's load all the "standard" modes # ok, now let's load all the "standard" modes
mode.install(self) mode.install(self)
@ -262,6 +263,16 @@ class Application(object):
curses.halfdelay(1) curses.halfdelay(1)
curses.def_prog_mode() curses.def_prog_mode()
def load_pmacs_methods(self, name):
exec("import %s" % name)
mod = eval(name)
for mname in dir(mod):
if mname.startswith('_'):
continue
cls = eval("%s.%s" % (name, mname))
if hasattr(cls, '_is_method') and cls._is_method:
self.methods[cls._name()] = cls()
def _load_config_defaults(self): def _load_config_defaults(self):
self.config['ignore_suffix'] = ['~', '-', 'CVS', '.svn', '.git', '.hg'] self.config['ignore_suffix'] = ['~', '-', 'CVS', '.svn', '.git', '.hg']
self.config['error_timeout'] = -1 self.config['error_timeout'] = -1