From 1ea5d18fa501e1bb4793b8d30e3b82b8b7fb8824 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Tue, 8 Nov 2011 22:32:03 -0500 Subject: [PATCH] abstract method loading --HG-- branch : pmacs2 --- application.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/application.py b/application.py index ed25b15..acb3893 100755 --- a/application.py +++ b/application.py @@ -156,14 +156,15 @@ class Application(object): 'method.git', ) for name in names: - 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() + self.load_pmacs_methods(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() # ok, now let's load all the "standard" modes mode.install(self) @@ -262,6 +263,16 @@ class Application(object): curses.halfdelay(1) 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): self.config['ignore_suffix'] = ['~', '-', 'CVS', '.svn', '.git', '.hg'] self.config['error_timeout'] = -1