summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-10-26 23:35:01 +0100
committerSean Finney <seanius@debian.org>2009-10-26 23:35:41 +0100
commit5057a6ff864c5b332f24e036c829cbbea940b918 (patch)
tree4c8eadf2f36c42d2d92023d58ff5e8f8d4e96bdc
parentc9ece47c49bb47a94603824ec709ba44a15ff07a (diff)
downloadpatch-tracker-5057a6ff864c5b332f24e036c829cbbea940b918.tar.gz
shuffle the logic in PackageCmd to allow exact matches for < 3 letters
-rwxr-xr-xpatchtracker/ReqHandler.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/patchtracker/ReqHandler.py b/patchtracker/ReqHandler.py
index c928bb6..af54116 100755
--- a/patchtracker/ReqHandler.py
+++ b/patchtracker/ReqHandler.py
@@ -91,14 +91,17 @@ class PackageCmd(Cmd):
else:
version = None
self.toc = db.findCollection(package=self.name, version=version)
- if self.toc.size() == 0:
- if len(self.name) >= 3:
+
+ # if there's no match, try with a wildcard match
+ if not self.toc.size():
+ # ... but don't allow pathologically short names
+ if len(self.name) < 3:
+ raise ReqHandlerException("search terms must be 3 or more letters...")
+ else:
self.toc = db.findCollection(package="%"+self.name+"%", version=version)
plist = self.toc.getletter(self.name)
- if len(self.name) < 3:
- raise ReqHandlerException("search terms must be 3 or more letters...")
- elif not plist or len(plist) == 0:
+ if not plist or len(plist) == 0:
raise ReqHandlerException("can't find any package named or containing '%s'"%self.name, code="404 ENOPKG kthxbye")
def output(self):