Created
June 6, 2011 18:24
-
-
Save FurryHead/1010770 to your computer and use it in GitHub Desktop.
Module to load all classes from modules located in package "plugins"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import exocet | |
import inspect | |
_ClassList = { } | |
def refresh(moduleName=None): | |
if moduleName is None: | |
_ClassList.clear() | |
modules = [m for m in exocet.getModule("plugins").iterModules()] | |
for module in modules: | |
m = module.load() | |
for name, obj in inspect.getmembers(m): | |
if inspect.isclass(obj): | |
_ClassList[name] = obj | |
#TODO: Add code to allow reloading classes from a specific module | |
def getPlugin(pluginClassName): | |
return _ClassList[pluginClassName] | |
refresh() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment