--- /dev/null
+I dunno, bugs everywhere is such a great mental image... ;)
--- /dev/null
+
+
+
+Content-type=text/plain
+
+
+
+
+
+
+Date=Sat, 15 Nov 2008 23:56:51 +0000
+
+
+
+
+
+
+From=wking
+
+
+
from libbe import names, plugin, cmdutil
import sys
import os
-import becommands.severity
-import becommands.status
-import becommands.list
-import becommands.show
-import becommands.set_root
-import becommands.new
-import becommands.close
-import becommands.open
-__doc__ = """Bugs Everywhere - Distributed bug tracking
-
-Supported becommands
- set-root: assign the root directory for bug tracking
- new: Create a new bug
- list: list bugs
- show: show a particular bug
- close: close a bug
- open: re-open a bug
- severity: %s
- status: %s
-
-Unimplemented becommands
- comment: append a comment to a bug
-""" % (becommands.severity.__desc__,
- becommands.status.__desc__)
-
+import becommands
+__doc__ == cmdutil.help()
if len(sys.argv) == 1 or sys.argv[1] in ('--help', '-h'):
- cmdutil.print_command_list()
+ print cmdutil.help()
else:
try:
try:
- sys.exit(execute(sys.argv[1], sys.argv[2:]))
+ sys.exit(cmdutil.execute(sys.argv[1], sys.argv[2:]))
except KeyError, e:
raise UserError("Unknown command \"%s\"" % e.args[0])
except cmdutil.GetHelp:
+"Command plugins for the BugsEverywhere be script."
+
+__all__ = ["set_root", "set", "new", "remove", "list", "show", "close", "open",
+ "assign", "severity", "status", "target", "comment", "diff",
+ "upgrade", "help"]
+
+def import_all():
+ for i in __all__:
+ name = __name__ + "." + i
+ try:
+ __import__(name, globals(), locals(), [])
+ except ImportError:
+ print "Import of %s failed!" % (name,)
+
+import_all()
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Close a bug"""
from libbe import cmdutil
+__desc__ = __doc__
+
def execute(args):
"""
>>> from libbe import tests
from libbe import cmdutil, names, utility
from libbe.bug import new_comment
import os
+__desc__ = __doc__
+
def execute(args):
"""
>>> from libbe import tests, names
"""Compare bug reports with older tree"""
from libbe import bugdir, diff, cmdutil
import os
+__desc__ = __doc__
+
def execute(args):
options, args = get_parser().parse_args(args)
if len(args) == 0:
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Print help for given subcommand"""
from libbe import cmdutil, names, utility
+__desc__ = __doc__
def execute(args):
"""
if len(args) > 1:
raise cmdutil.UserError("Too many arguments.")
if len(args) == 0:
- cmdutil.print_command_list()
+ print cmdutil.help()
else:
try:
print cmdutil.help(args[0])
from libbe.bug import cmp_full, severity_values, status_values, \
active_status_values, inactive_status_values
import os
+__desc__ = __doc__
+
def execute(args):
options, args = get_parser().parse_args(args)
if len(args) > 0:
"""Create a new bug"""
from libbe import cmdutil, names, utility
from libbe.bug import new_bug
+__desc__ = __doc__
def execute(args):
"""
bug.summary = args[0]
bug.save()
bugs = (dir.list())
- print "Created bug with ID %s" % cmdutil.unique_name(bug, bugs)
+ print "Created bug with ID %s" % names.unique_name(bug, bugs)
def get_parser():
parser = cmdutil.CmdOptionParser("be new SUMMARY")
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Re-open a bug"""
from libbe import cmdutil
+__desc__ = __doc__
+
def execute(args):
"""
>>> from libbe import tests
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Change tree settings"""
from libbe import cmdutil
+__desc__ = __doc__
+
def execute(args):
"""
>>> from libbe import tests
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Assign the root directory for bug tracking"""
from libbe import bugdir, cmdutil, rcs
+__desc__ = __doc__
def execute(args):
"""
"""Show or change a bug's severity level"""
from libbe import cmdutil
from libbe.bug import severity_values, severity_description
-
__desc__ = __doc__
def execute(args):
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Show a particular bug"""
-from libbe import cmdutil, utility
+from libbe import cmdutil, names, utility
from libbe.bug import thread_comments
import os
+__desc__ = __doc__
def execute(args):
options, args = get_parser().parse_args(args)
bug_dir = cmdutil.bug_tree()
bug = cmdutil.get_bug(args[0], bug_dir)
print bug.string().rstrip("\n")
- unique_name = cmdutil.unique_name(bug, bug_dir.list())
+ unique_name = names.unique_name(bug, bug_dir.list())
comments = []
name_map = {}
for c_name, comment in cmdutil.iter_comment_name(bug, unique_name):
+++ /dev/null
-"""Short description"""
-from libbe import bugdir, cmdutil, names
-import os
-def execute(args):
- options, args = get_parser().parse_args(args)
- if len(args) > 0:
- raise cmdutil.UsageError
-
-
-def get_parser():
- parser = cmdutil.CmdOptionParser("be list [options]")
-# parser.add_option("-w", "--wishlist", action="store_true", dest="wishlist",
-# help="List bugs with 'wishlist' severity")
- return parser
-
-longhelp="""
-This is for the longwinded description
-"""
-
-def help():
- return get_parser().help_str() + longhelp
import os.path
import errno
from libbe import bugdir, rcs, cmdutil
+__desc__ = __doc__
def execute(args):
options, args = get_parser().parse_args(args)
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
import os.path
+import shutil
import errno
import names
-import cmdutil
import mapfile
import time
import utility
def string(self, bugs=None, shortlist=False):
if bugs == None:
bugs = list(self.bugdir.list())
- short_name = cmdutil.unique_name(self, bugs)
+ short_name = names.unique_name(self, bugs)
if shortlist == False:
htime = utility.handy_time(self.time)
ftime = utility.time_to_str(self.time)
newinfo.append((k,v))
info = newinfo
longest_key_len = max([len(k) for k,v in info])
- infolines = [" %*s : %s\n" % (longest_key_len,k,v) for k,v in info]
+ infolines = [" %*s : %s\n" %(longest_key_len,k,v) for k,v in info]
return "".join(infolines) + "%s\n" % self.summary
else:
statuschar = self.status[0]
return "%s:%s: %s\n" % (short_name, chars, self.summary)
def __str__(self):
return self.string(shortlist=True)
- def get_path(self, file):
- return os.path.join(self.path, self.uuid, file)
+ def get_path(self, file=None):
+ if file == None:
+ return os.path.join(self.path, self.uuid)
+ else:
+ return os.path.join(self.path, self.uuid, file)
def _get_active(self):
return self.status in active_status_values
map["time"] = utility.time_to_str(self.time)
path = self.get_path("values")
mapfile.map_save(rcs_by_name(self.rcs_name), path, map)
-
+
+ def remove(self):
+ path = self.get_path()
+ shutil.rmtree(path)
+
def _get_rcs(self):
return rcs_by_name(self.rcs_name)
def save(self):
map_file = {"Date": utility.time_to_str(self.time)}
add_headers(self, map_file, ("From", "in_reply_to", "content_type"))
- if not os.path.exists(self.get_path(None)):
- self.bug.rcs.mkdir(self.get_path(None))
+ if not os.path.exists(self.get_path()):
+ self.bug.rcs.mkdir(self.get_path())
mapfile.map_save(self.bug.rcs, self.get_path("values"), map_file)
self.bug.rcs.set_file_contents(self.get_path("body"),
self.body.encode('utf-8'))
- def get_path(self, name):
+ def get_path(self, name=None):
my_dir = os.path.join(self.bug.get_path("comments"), self.uuid)
if name is None:
return my_dir
from StringIO import StringIO
import utility
-def unique_name(bug, bugs):
- """
- Generate short names from uuids. Picks the minimum number of
- characters (>=3) from the beginning of the uuid such that the
- short names are unique.
-
- Obviously, as the number of bugs in the database grows, these
- short names will cease to be unique. The complete uuid should be
- used for long term reference.
- """
- chars = 3
- for some_bug in bugs:
- if bug.uuid == some_bug.uuid:
- continue
- while (bug.uuid[:chars] == some_bug.uuid[:chars]):
- chars+=1
- return bug.uuid[:chars]
-
class UserError(Exception):
def __init__(self, msg):
Exception.__init__(self, msg)
encoding = locale.getpreferredencoding() or 'ascii'
return get_command(cmd).execute([a.decode(encoding) for a in args])
-def help(cmd):
- return get_command(cmd).help()
-
+def help(cmd=None):
+ if cmd != None:
+ return get_command(cmd).help()
+ else:
+ cmdlist = []
+ for name, module in iter_commands():
+ cmdlist.append((name, module.__desc__))
+ longest_cmd_len = max([len(name) for name,desc in cmdlist])
+ ret = ["Bugs Everywhere - Distributed bug tracking\n",
+ "Supported commands"]
+ for name, desc in cmdlist:
+ numExtraSpaces = longest_cmd_len-len(name)
+ ret.append("be %s%*s %s" % (name, numExtraSpaces, "", desc))
+ return "\n".join(ret)
class GetHelp(Exception):
pass
except bugdir.NoBugDir, e:
raise UserErrorWrap(e)
-def print_command_list():
- cmdlist = []
- print """Bugs Everywhere - Distributed bug tracking
-
-Supported commands"""
- for name, module in iter_commands():
- cmdlist.append((name, module.__doc__))
- for name, desc in cmdlist:
- print "be %s\n %s" % (name, desc)
def _test():
import doctest
return os.environ["LOGNAME"]
else:
return os.environ["USERNAME"]
+
+def unique_name(bug, bugs):
+ """
+ Generate short names from uuids. Picks the minimum number of
+ characters (>=3) from the beginning of the uuid such that the
+ short names are unique.
+
+ Obviously, as the number of bugs in the database grows, these
+ short names will cease to be unique. The complete uuid should be
+ used for long term reference.
+ """
+ chars = 3
+ for some_bug in bugs:
+ if bug.uuid == some_bug.uuid:
+ continue
+ while (bug.uuid[:chars] == some_bug.uuid[:chars]):
+ chars+=1
+ return bug.uuid[:chars]
plugin_path = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))
if plugin_path not in sys.path:
sys.path.append(plugin_path)
+
def _test():
import doctest
doctest.testmod()