QueryCommand: add get_db() classmethod
authorZac Medico <zmedico@gentoo.org>
Mon, 11 Jun 2012 22:37:30 +0000 (15:37 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 11 Jun 2012 22:37:30 +0000 (15:37 -0700)
pym/portage/package/ebuild/_ipc/QueryCommand.py

index 7bbb0e83bdc7c1e522805894a5a5188f9b91db82..d200fe80d12533dff6ef144ffb75e746b2b169fb 100644 (file)
@@ -20,6 +20,12 @@ class QueryCommand(IpcCommand):
 
        _db = None
 
+       @classmethod
+       def get_db(cls):
+               if cls._db is not None:
+                       return cls._db
+               return portage.db
+
        def __init__(self, settings, phase):
                IpcCommand.__init__(self)
                self.settings = settings
@@ -52,9 +58,7 @@ class QueryCommand(IpcCommand):
                use = frozenset(use.split())
                atom = atom.evaluate_conditionals(use)
 
-               db = self._db
-               if db is None:
-                       db = portage.db
+               db = self.get_db()
 
                warnings_str = ''
                if warnings: