summaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
authorgenone <genone@gentoo.org>2004-02-06 23:10:19 +0000
committergenone <genone@gentoo.org>2004-02-06 23:10:19 +0000
commit6f8dc603ab3f7ea14786f631f18efe67b1e30640 (patch)
tree332e9c0d9ecdf789804b64cb6241b025b3f5859f /trunk/src
parentfa07cbc87a1ef98355979aea13b066dbe76c8a16 (diff)
downloadgentoolkit-6f8dc603ab3f7ea14786f631f18efe67b1e30640.tar.gz
moved the 'ambigous package' check into gentoolkit.find_packages, so it returns all matching packages
svn path=/; revision=79
Diffstat (limited to 'trunk/src')
-rw-r--r--trunk/src/gentoolkit/gentoolkit.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/trunk/src/gentoolkit/gentoolkit.py b/trunk/src/gentoolkit/gentoolkit.py
index b300c39..9b2eec7 100644
--- a/trunk/src/gentoolkit/gentoolkit.py
+++ b/trunk/src/gentoolkit/gentoolkit.py
@@ -23,6 +23,7 @@ sys.path.insert(0, "/usr/lib/portage/pym")
import portage
import re
import string
+import types
settings = portage.config(clone=portage.settings)
porttree = portage.db[portage.root]["porttree"]
@@ -183,10 +184,22 @@ class Package:
def find_packages(search_key, masked=False):
"""Returns a list of Package objects that matched the search key."""
- if masked:
- t=portage.portdb.xmatch("match-all", search_key)
- else:
- t=portage.portdb.match(search_key)
+ try:
+ if masked:
+ t=portage.portdb.xmatch("match-all", search_key)
+ else:
+ t=portage.portdb.match(search_key)
+ # catch the "amgigous package" Exception
+ except ValueError, e:
+ if type(e[0]) == types.ListType:
+ t=[]
+ for cp in e[0]:
+ if masked:
+ t += portage.portdb.xmatch("match-all", cp)
+ else:
+ t += portage.portdb.match(cp)
+ else:
+ raise ValueError(e)
return [Package(x) for x in t]
def find_best_match(search_key):