diff options
author | Krzysztof A. Adamski <krzysztofa@gmail.com> | 2008-08-02 19:41:40 -0400 |
---|---|---|
committer | Krzysztof A. Adamski <krzysztofa@gmail.com> | 2008-08-07 18:29:22 -0400 |
commit | b2ea14876b07a9a2a64adbb0ddd824e15c674ffe (patch) | |
tree | 479d2ed287b92440d478c1e78abba377cf59a25c /func/module_loader.py | |
parent | 4a17d134e0f5a3880a4ba0d930e2d37485c8b1a2 (diff) | |
download | func-b2ea14876b07a9a2a64adbb0ddd824e15c674ffe.tar.gz func-b2ea14876b07a9a2a64adbb0ddd824e15c674ffe.tar.xz func-b2ea14876b07a9a2a64adbb0ddd824e15c674ffe.zip |
Adding overlord modules support.
Diffstat (limited to 'func/module_loader.py')
-rwxr-xr-x | func/module_loader.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/func/module_loader.py b/func/module_loader.py index f418f80..a999de7 100755 --- a/func/module_loader.py +++ b/func/module_loader.py @@ -16,6 +16,7 @@ import distutils.sysconfig import os import sys +import inspect from gettext import gettext _ = gettext @@ -36,9 +37,17 @@ def module_walker(topdir): # in the module name, and foo..bar doesnt work -akl module_files.append(os.path.normpath("%s/%s" % (root, filename))) - return module_files +def load_methods(path, main_class): + methods = {} + modules = load_modules(path, main_class) + for x in modules.keys(): + for method in dir(modules[x]): + if is_public_valid_method(modules[x], method): + methods["%s.%s" % (x,method)]=getattr(modules[x], method) + return methods + def load_modules(path='func/minion/modules/', main_class=func_module.FuncModule, blacklist=None): python_path = distutils.sysconfig.get_python_lib() @@ -103,6 +112,14 @@ def load_modules(path='func/minion/modules/', main_class=func_module.FuncModule, return mods +def is_public_valid_method(obj, attr, blacklist=[]): + if inspect.ismethod(getattr(obj, attr)) and attr[0] != '_': + for b in blacklist: + if attr==b: + return False + return True + return False + if __name__ == "__main__": |