aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/util/id.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2010-01-30 11:24:39 -0500
committerW. Trevor King <wking@drexel.edu>2010-01-30 11:24:39 -0500
commit77bcd2ab6cd0afafc4c9ce8ec720fa167f1baeaf (patch)
treedb01cd2ac294b12d71c0868688c9a831ff0e20e8 /libbe/util/id.py
parent3a1f36b08835772fb80141f57220b0460e1fc67b (diff)
downloadbugseverywhere-77bcd2ab6cd0afafc4c9ce8ec720fa167f1baeaf.tar.gz
libbe.command.html.HTMLGen._long_to_linked_user() handles failed conversion.
Before, anything matching libbe.util.id.REGEXP was convert-or-die. Now it's convert-or-no-op. Much safer ;). The new _long_to_linked_user doctest would have failed with the old implementation.
Diffstat (limited to 'libbe/util/id.py')
-rw-r--r--libbe/util/id.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/libbe/util/id.py b/libbe/util/id.py
index 3c6c957..81f5396 100644
--- a/libbe/util/id.py
+++ b/libbe/util/id.py
@@ -69,7 +69,7 @@ HIERARCHY = ['bugdir', 'bug', 'comment']
class MultipleIDMatches (ValueError):
def __init__(self, id, common, matches):
msg = ('More than one id matches %s. '
- 'Please be more specific (%s/*).\n%s' % (id, common, matches))
+ 'Please be more specific (%s*).\n%s' % (id, common, matches))
ValueError.__init__(self, msg)
self.id = id
self.common = common
@@ -249,7 +249,12 @@ def child_uuids(child_storage_ids):
def long_to_short_user(bugdirs, id):
ids = _split(id, check_length=True)
- bugdir = [bd for bd in bugdirs if bd.uuid == ids[0]][0]
+ matching_bugdirs = [bd for bd in bugdirs if bd.uuid == ids[0]]
+ if len(matching_bugdirs) == 0:
+ raise NoIDMatches(id, [bd.uuid for bd in bugdirs])
+ elif len(matching_bugdirs) > 1:
+ raise MultipleIDMatches(id, '', [bd.uuid for bd in bugdirs])
+ bugdir = matching_bugdirs[0]
objects = [bugdir]
if len(ids) >= 2:
bug = bugdir.bug_from_uuid(ids[1])