aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/command/util.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-14 07:37:51 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-14 07:37:51 -0500
commit19fe0817ba7c2cd04caea3adfa82d4490288a548 (patch)
tree6291cac9b9861f1009d63a419c3e79879f356bc8 /libbe/command/util.py
parent2f0ceedba5b6619faf476cd1aa67e826e91d5c7c (diff)
downloadbugseverywhere-19fe0817ba7c2cd04caea3adfa82d4490288a548.tar.gz
Transitioned comment to Command format
Diffstat (limited to 'libbe/command/util.py')
-rw-r--r--libbe/command/util.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/libbe/command/util.py b/libbe/command/util.py
index 98b2081..4395592 100644
--- a/libbe/command/util.py
+++ b/libbe/command/util.py
@@ -43,6 +43,8 @@ def complete_extra_strings(command, argument, fragment=None):
return [fragment]
def complete_bug_id(command, argument, fragment=None):
return [fragment]
+def complete_bug_comment_id(command, argument, fragment=None):
+ return [fragment]
def select_values(string, possible_values, name="unkown"):
"""
@@ -96,3 +98,19 @@ def select_values(string, possible_values, name="unkown"):
% (name, value, possible_values))
possible_values = whitelisted_values
return possible_values
+
+def bug_comment_from_user_id(bugdir, id):
+ p = libbe.util.id.parse_user(bugdir, id)
+ if not p['type'] in ['bug', 'comment']:
+ raise libbe.command.UserError(
+ '%s is a %s id, not a bug or comment id' % (id, p['type']))
+ if p['bugdir'] != bugdir.uuid:
+ raise libbe.command.UserError(
+ "%s doesn't belong to this bugdir (%s)"
+ % (id, bugdir.uuid))
+ bug = bugdir.bug_from_uuid(p['bug'])
+ if 'comment' in p:
+ comment = bug.comment_from_uuid(p['comment'])
+ else:
+ comment = bug.comment_root
+ return (bug, comment)