aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/plugins/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'MgaRepo/plugins/__init__.py')
-rw-r--r--MgaRepo/plugins/__init__.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/MgaRepo/plugins/__init__.py b/MgaRepo/plugins/__init__.py
new file mode 100644
index 0000000..1eeb3bb
--- /dev/null
+++ b/MgaRepo/plugins/__init__.py
@@ -0,0 +1,27 @@
+import os
+
+loaded = {}
+
+def load():
+ # based on smart's plugin system
+ pluginsdir = os.path.dirname(__file__)
+ for entry in os.listdir(pluginsdir):
+ if entry != "__init__.py" and entry.endswith(".py"):
+ name = entry[:-3]
+ loaded[name] = __import__("MgaRepo.plugins."+name, {}, {},
+ [name])
+ elif os.path.isdir(entry):
+ initfile = os.path.join(entry, "__init__.py")
+ if os.path.isfile(initfile):
+ loaded[entry] = __import__("MgaRepo.plugins."+entry, {}, {},
+ [entry])
+
+def list():
+ return loaded.keys()
+
+def help(name):
+ from MgaRepo import Error
+ try:
+ return loaded[name].__doc__
+ except KeyError:
+ raise Error, "plugin %s not found" % name