Added find_installed_packages
authorkarltk <karltk@gentoo.org>
Mon, 27 Sep 2004 11:10:16 +0000 (11:10 -0000)
committerkarltk <karltk@gentoo.org>
Mon, 27 Sep 2004 11:10:16 +0000 (11:10 -0000)
svn path=/; revision=138

trunk/src/gentoolkit/ChangeLog
trunk/src/gentoolkit/gentoolkit.py

index dcb7a61b694129482ef24fca6af21fe9a0a122bc..5ea8ae42181bea5fa69f66b0d260d7db6357e279 100644 (file)
@@ -1,3 +1,6 @@
+2004-09-27: Karl Trygve Kalleberg <karltk@gentoo.org>
+       * Added find_installed_packages
+
 2004-09-08: Karl Trygve Kalleberg <karltk@gentoo.org>
        * Reworked printing functions
 
index a7f2f4d5fe7a2a4fe7932a33e063e41c4fad8a47..50aad813a3bc7b0e57d0b3a5116c0f5337bc3cc1 100644 (file)
@@ -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"""