def plugins(self): import imp plugins_dir = self.dirs.plugins plugins = {} for filename in os.listdir(plugins_dir): abs_filename = read_symlink(filename, plugins_dir) path, filename = split(abs_filename) name, ext = splitext(filename) fp, fn, desc = imp.find_module(name, [path]) plugin_module = imp.load_module(name, fp, fn, desc) for hook, func in vars(plugin_module).items(): if hook in HOOKS: if not hook in plugins: plugins[hook] = {} plugins[hook][abs_filename] = func return plugins
def subprojects(self): subprojects_dir = self.dirs.subprojects return {name: Project(read_symlink(name, subprojects_dir)) for name in os.listdir(subprojects_dir)}