Rework portage_utils' find_packages to work with old and new gentoolkits.
authorW. Trevor King <wking@drexel.edu>
Tue, 7 Jun 2011 00:55:30 +0000 (20:55 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 7 Jun 2011 00:55:30 +0000 (20:55 -0400)
g_pypi/portage_utils.py

index c9042d8cb67e5f19a79c9735bd6385c4ca03e6fe..1a27bd61f410aadcad2818bec4b777c2203b3a28 100644 (file)
@@ -31,7 +31,13 @@ try:
 except ImportError:  # earlier versions in '/usr/lib/gentoolkit/pym'
     sys.path.append(os.path.join('/usr', 'lib', 'gentoolkit', 'pym'))
     import gentoolkit
-import gentoolkit.query
+
+try:
+    import gentoolkit.query  # gentoolkit since 0.3.0
+    def find_packages(key):
+        return gentoolkit.query.Query(cat_pkg).find()        
+except ImportError:  # earlier versions
+    from gentoolkit.helpers import find_packages
 
 
 __docformat__ = 'restructuredtext'
@@ -107,7 +113,7 @@ def ebuild_exists(cat_pkg):
     @returns: True if ebuild exists, False if no ebuild exists
     """
 
-    pkgs = gentoolkit.query.Query(cat_pkg).find()
+    pkgs = find_packages(cat_pkg)
     if len(pkgs):
         return True
     else: