From 7a67efb3bc61ec499c9af7de7c54a7b98db7eafd Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 27 Nov 2008 11:34:44 -0500 Subject: Added becommands/comment completion. --- libbe/bug.py | 9 ++++++++- libbe/cmdutil.py | 1 - libbe/comment.py | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'libbe') diff --git a/libbe/bug.py b/libbe/bug.py index 67051f2..f47bcba 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -183,7 +183,7 @@ class Bug(object): if self._comments_loaded == False: self.load_comments() # take advantage of the string_thread(auto_name_map=True) - # SIDE-EFFECT of sorting by bug time. + # SIDE-EFFECT of sorting by comment time. comout = self.comment_root.string_thread(flatten=False, auto_name_map=True, bug_shortname=shortname) @@ -272,6 +272,13 @@ class Bug(object): def comment_from_uuid(self, uuid): return self.comment_root.comment_from_uuid(uuid) + def comment_shortnames(self, shortname=None): + """ + SIDE-EFFECT : Comment.comment_shortnames will sort the comment + tree by comment.time + """ + for id, comment in self.comment_root.comment_shortnames(shortname): + yield (id, comment) # the general rule for bug sorting is that "more important" bugs are # less than "less important" bugs. This way sorting a list of bugs diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py index 0382664..eefed58 100644 --- a/libbe/cmdutil.py +++ b/libbe/cmdutil.py @@ -156,7 +156,6 @@ def default_complete(options, args, parser, bugid_args={}): bugs = [bug for bug in bd if filter(bug) == True] bugshortnames = [bd.bug_shortname(bug) for bug in bugs] except bugdir.NoBugDir: - bugshortnames = ["NOBUGDIR"] pass raise GetCompletions(bugshortnames) raise GetCompletions() diff --git a/libbe/comment.py b/libbe/comment.py index 0c8372e..ab0973d 100644 --- a/libbe/comment.py +++ b/libbe/comment.py @@ -249,7 +249,7 @@ class Comment(Tree): Return a sting displaying a thread of comments. bug_shortname is only used if auto_name_map == True. - SIDE-EFFECT: if auto_name_map==True, calls comment_shornames() + SIDE-EFFECT: if auto_name_map==True, calls comment_shortnames() which will sort the tree by comment.time. Avoid by calling name_map = {} for shortname,comment in comm.comment_shortnames(bug_shortname): @@ -334,7 +334,7 @@ class Comment(Tree): stringlist.append(comment.string(indent=ind, shortname=sname)) return '\n'.join(stringlist) - def comment_shortnames(self, bug_shortname=""): + def comment_shortnames(self, bug_shortname=None): """ Iterate through (id, comment) pairs, in time order. (This is a user-friendly id, not the comment uuid). @@ -355,6 +355,8 @@ class Comment(Tree): bug-1:3 c bug-1:4 d """ + if bug_shortname == None: + bug_shortname = "" self.sort(key=lambda comm : comm.time) for num,comment in enumerate(self.traverse()): yield ("%s:%d" % (bug_shortname, num+1), comment) -- cgit