#!/usr/bin/env python
from libbe.cmdutil import *
from libbe.bugdir import tree_root, create_bug_dir
-from libbe import names
+from libbe import names, plugin, cmdutil
import sys
import os
import becommands.severity
if len(sys.argv) == 1:
- print __doc__
+ cmdlist = []
+ print """Bugs Everywhere - Distributed bug tracking
+
+Supported commands"""
+ for name, module in cmdutil.iter_commands():
+ cmdlist.append((name, module.__doc__))
+ for name, desc in cmdlist:
+ print "%s: %s" % (name, desc)
else:
try:
try:
+"""Close a bug"""
from libbe import cmdutil
def execute(args):
assert(len(args) == 1)
+"""List bugs"""
from libbe import bugdir, cmdutil
import os
def execute(args):
+"""Create a new bug"""
from libbe import bugdir, cmdutil, names
def execute(args):
if len(args) != 1:
+"""Re-open a bug"""
from libbe import cmdutil
def execute(args):
assert(len(args) == 1)
+"""Assign the root directory for bug tracking"""
from libbe import bugdir, cmdutil
def execute(args):
+"""Show a particular bug"""
from libbe import bugdir, cmdutil
import os
import bugdir
+import plugin
def unique_name(bug, bugs):
chars = 1
for some_bug in bugs:
(unique_name(bug, bugs), bug.severity, target, bug.creator,
bug.summary)
+def iter_commands():
+ return plugin.iter_plugins("becommands")
+
+def execute(cmd, args):
+ return plugin.get_plugin("becommands", cmd).execute(args)
+
+def help(cmd, args):
+ return plugin.get_plugin("becommands", cmd).help()
--- /dev/null
+import os
+import os.path
+import sys
+def my_import(mod_name):
+ module = __import__(mod_name)
+ components = mod_name.split('.')
+ for comp in components[1:]:
+ module = getattr(module, comp)
+ return module
+
+def iter_plugins(prefix):
+ modfiles = os.listdir(os.path.join(sys.path[0], prefix))
+ modfiles.sort()
+ for modfile in modfiles:
+ if modfile.endswith(".py") and modfile != "__init__.py":
+ yield modfile[:-3], my_import(prefix+"."+modfile[:-3])
+
+
+def get_plugin(prefix, name):
+ dirprefix = '/'.join(prefix.split('.'))
+ command_path = os.path.join(sys.path[0], dirprefix, name+".py")
+ if os.path.isfile(command_path):
+ return my_import(prefix + "." + name)
+ return None
+