From: karltk Date: Mon, 27 Sep 2004 11:10:16 +0000 (-0000) Subject: Added find_installed_packages X-Git-Tag: gentoolkit-0.2.4.3~364 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=075b83b34d11ffd263cc69311e60cd33f26f54a8;p=gentoolkit.git Added find_installed_packages svn path=/; revision=138 --- diff --git a/trunk/src/gentoolkit/ChangeLog b/trunk/src/gentoolkit/ChangeLog index dcb7a61..5ea8ae4 100644 --- a/trunk/src/gentoolkit/ChangeLog +++ b/trunk/src/gentoolkit/ChangeLog @@ -1,3 +1,6 @@ +2004-09-27: Karl Trygve Kalleberg + * Added find_installed_packages + 2004-09-08: Karl Trygve Kalleberg * Reworked printing functions diff --git a/trunk/src/gentoolkit/gentoolkit.py b/trunk/src/gentoolkit/gentoolkit.py index a7f2f4d..50aad81 100644 --- a/trunk/src/gentoolkit/gentoolkit.py +++ b/trunk/src/gentoolkit/gentoolkit.py @@ -215,6 +215,20 @@ def find_packages(search_key, masked=False): raise ValueError(e) return [Package(x) for x in t] +def find_installed_packages(search_key, masked=False): + """Returns a list of Package objects that matched the search key.""" + try: + t = vartree.dbapi.match(search_key) + # catch the "amgigous package" Exception + except ValueError, e: + if type(e[0]) == types.ListType: + t=[] + for cp in e[0]: + t += vartree.dbapi.match(cp) + else: + raise ValueError(e) + return [Package(x) for x in t] + def find_best_match(search_key): """Returns a Package object for the best available installed candidate that matched the search key. Doesn't handle virtuals perfectly"""