portageq: avoid portdbapi instantiation
authorZac Medico <zmedico@gentoo.org>
Sat, 13 Jul 2013 18:19:27 +0000 (11:19 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 13 Jul 2013 18:19:27 +0000 (11:19 -0700)
The portdbapi takes time to instantiate, and for some commands we
really only need the  RepoConfig instance.

bin/portageq

index 4be9f889069c0d84b209bf1d3f5e74e5feec04cd..0e1cb6408f24204f6844e2e1dee353f1fe07c6a7 100755 (executable)
@@ -725,7 +725,7 @@ def get_repos(argv):
        if len(argv) < 1:
                print("ERROR: insufficient parameters!")
                return 2
-       print(" ".join(portage.db[argv[0]]["porttree"].dbapi.getRepositories()))
+       print(" ".join(reversed(portage.db[argv[0]]["vartree"].settings.repositories.prepos_order)))
 
 get_repos.uses_eroot = True
 
@@ -741,7 +741,7 @@ def master_repositories(argv):
                        print("ERROR: invalid repository: %s" % arg, file=sys.stderr)
                        return 2
                try:
-                       repo = portage.db[argv[0]]["porttree"].dbapi.repositories[arg]
+                       repo = portage.db[argv[0]]["vartree"].settings.repositories[arg]
                except KeyError:
                        print("")
                        return 1
@@ -761,7 +761,7 @@ def get_repo_path(argv):
                if portage.dep._repo_name_re.match(arg) is None:
                        print("ERROR: invalid repository: %s" % arg, file=sys.stderr)
                        return 2
-               path = portage.db[argv[0]]["porttree"].dbapi.getRepositoryPath(arg)
+               path = portage.db[argv[0]]["vartree"].settings.repositories.treemap.get(arg)
                if path is None:
                        print("")
                        return 1
@@ -781,7 +781,7 @@ def available_eclasses(argv):
                        print("ERROR: invalid repository: %s" % arg, file=sys.stderr)
                        return 2
                try:
-                       repo = portage.db[argv[0]]["porttree"].dbapi.repositories[arg]
+                       repo = portage.db[argv[0]]["vartree"].settings.repositories[arg]
                except KeyError:
                        print("")
                        return 1
@@ -801,7 +801,7 @@ def eclass_path(argv):
                print("ERROR: invalid repository: %s" % argv[1], file=sys.stderr)
                return 2
        try:
-               repo = portage.db[argv[0]]["porttree"].dbapi.repositories[argv[1]]
+               repo = portage.db[argv[0]]["vartree"].settings.repositories[argv[1]]
        except KeyError:
                print("")
                return 1
@@ -830,7 +830,7 @@ def license_path(argv):
                print("ERROR: invalid repository: %s" % argv[1], file=sys.stderr)
                return 2
        try:
-               repo = portage.db[argv[0]]["porttree"].dbapi.repositories[argv[1]]
+               repo = portage.db[argv[0]]["vartree"].settings.repositories[argv[1]]
        except KeyError:
                print("")
                return 1