Skip to content

Instantly share code, notes, and snippets.

@FurryHead
Created June 6, 2011 18:24
Show Gist options
  • Save FurryHead/1010770 to your computer and use it in GitHub Desktop.
Save FurryHead/1010770 to your computer and use it in GitHub Desktop.
Module to load all classes from modules located in package "plugins"
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