from gentoolkit.atom import Atom
from gentoolkit.cpv import CPV
from gentoolkit.helpers import uniqify
-from gentoolkit.dbapi import PORTDB, VARDB
from gentoolkit.query import Query
# =======
# Try to use the Portage tree first, since emerge only uses the tree
# when calculating dependencies
try:
- result = PORTDB.aux_get(self.cpv, envvars)
+ result = portage.db[portage.root]["porttree"].dbapi.aux_get(self.cpv, envvars)
except KeyError:
try:
- result = VARDB.aux_get(self.cpv, envvars)
+ result = portage.db[portage.root]["vartree"].dbapi.aux_get(self.cpv, envvars)
except KeyError:
return []
return result
import sys
import gentoolkit
-from gentoolkit.dbapi import PORTDB, VARDB
from gentoolkit.module_base import ModuleBase
from gentoolkit import pprinter as pp
from gentoolkit.flag import get_installed_use, get_flags
@rtype dict. {flag:{"+":[cat/pkg-ver,...], "-":[cat/pkg-ver,...], "unset":[]}
"""
if cpvs is None:
- cpvs = VARDB.cpv_all()
+ cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
# pass them in to override for tests
flags = FlagAnalyzer(system_flags,
filter_defaults=False,
@rtype dict. {keyword:{"stable":[cat/pkg-ver,...], "testing":[cat/pkg-ver,...]}
"""
if cpvs is None:
- cpvs = VARDB.cpv_all()
+ cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
keyword_users = {}
for cpv in cpvs:
if cpv.startswith("virtual"):
self.options["verbose"],
system_use)
if self.options["verbose"]:
- cpvs = VARDB.cpv_all()
+ cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
#cpvs = get_installed_cpvs()
#print "Total number of installed ebuilds =", len(cpvs)
flag_users = gather_flags_info(cpvs, system_use,
"keywords",
self.options["verbose"],
system_keywords)
- self.analyser = KeywordAnalyser( arch, system_keywords, VARDB)
+ self.analyser = KeywordAnalyser( arch, system_keywords, portage.db[portage.root]["vartree"].dbapi)
#self.analyser.set_order(portage.settings["USE"].split())
# only for testing
test_use = portage.settings["USE"].split()
# /end testing
if self.options["verbose"]:
- cpvs = VARDB.cpv_all()
+ cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
#print "Total number of installed ebuilds =", len(cpvs)
keyword_users = gather_keywords_info(
cpvs=cpvs,
"""
system_use = portage.settings["USE"].split()
if self.options["verbose"]:
- cpvs = VARDB.cpv_all()
+ cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
key_width = 45
else:
cpvs = get_installed_cpvs()
import sys
-from gentoolkit.dbapi import PORTDB, VARDB
from gentoolkit import errors
from gentoolkit.keyword import reduce_keywords
from gentoolkit.flag import (reduce_flags, get_flags, get_all_cpv_use,
@param arch: the system ARCH setting
@type accept_keywords: list
@param accept_keywords: eg. ['x86', '~x86']
- @type get_aux: function, defaults to: VARDB.aux_get
+ @type get_aux: function, defaults to: portage.db[portage.root]["vartree"].dbapi.aux_get
@param vardb: vardb class of functions, needed=aux_get()
to return => KEYWORDS & USE flags for a cpv
= aux_get(cpv, ["KEYWORDS", "USE"])
parse_range = list(range(len(normal_order)))
- def __init__(self, arch, accept_keywords, vardb=VARDB):
+ def __init__(self, arch, accept_keywords, vardb=portage.db[portage.root]["vartree"].dbapi):
self.arch = arch
self.accept_keywords = accept_keywords
self.vardb = vardb
self.parse_order = self.normal_order
self.keyword = self.arch
#print "SET_ORDER() completed: prefix =", self.prefix, ", keyword =", \
- # self.keyword, "parse order =",self.parse_order
+ # self.keyword, "parse order =",self.parse_order
#print
import sys
import gentoolkit
-from gentoolkit.dbapi import PORTDB, VARDB
from gentoolkit.module_base import ModuleBase
from gentoolkit import pprinter as pp
from gentoolkit.enalyze.lib import (get_installed_use, get_flags, FlagAnalyzer,
@rtype dict. {cpv:['flag1', '-flag2',...]}
"""
if cpvs is None:
- cpvs = VARDB.cpv_all()
+ cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
cpvs.sort()
data = {}
cp_counts = {}
for cpv in cpvs:
plus, minus, unset = flags.analyse_cpv(cpv)
atom = Atom("="+cpv)
- atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0]
+ atom.slot = portage.db[portage.root]["vartree"].dbapi.aux_get(atom.cpv, ["SLOT"])[0]
for flag in minus:
plus.add("-"+flag)
if len(plus):
"testing":[cat/pkg-ver,...]}
"""
if cpvs is None:
- cpvs = VARDB.cpv_all()
+ cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
keyword_users = {}
cp_counts = {}
for cpv in cpvs:
cp_counts[atom.cp] = 0
if key in ["~"]:
atom.keyword = keyword
- atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0]
+ atom.slot = portage.db[portage.root]["vartree"].dbapi.aux_get(atom.cpv, ["SLOT"])[0]
keyword_users[atom.cp].append(atom)
cp_counts[atom.cp] += 1
elif key in ["-"]:
#print "adding cpv to missing:", cpv
atom.keyword = "**"
- atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0]
+ atom.slot = portage.db[portage.root]["vartree"].dbapi.aux_get(atom.cpv, ["SLOT"])[0]
keyword_users[atom.cp].append(atom)
cp_counts[atom.cp] += 1
return keyword_users, cp_counts
if self.options["verbose"] or self.options["prefix"]:
print("Current system ARCH =", arch)
print("Current system ACCEPT_KEYWORDS =", system_keywords)
- self.analyser = KeywordAnalyser( arch, system_keywords, VARDB)
+ self.analyser = KeywordAnalyser( arch, system_keywords, portage.db[portage.root]["vartree"].dbapi)
#self.analyser.set_order(portage.settings["USE"].split())
# only for testing
test_use = portage.settings["USE"].split()
self.analyser.set_order(test_use)
# /end testing
- cpvs = VARDB.cpv_all()
+ cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
#print "Total number of installed ebuilds =", len(cpvs)
pkgs, cp_counts = cpv_all_diff_keywords(
cpvs=cpvs,
import sys
-from gentoolkit.dbapi import PORTDB, VARDB
-
import portage
"""
try:
# aux_get might return dupes, so run them through set() to remove them
- return list(set(PORTDB.aux_get(cpv, ["IUSE"])[0].split()))
+ return list(set(portage.db[portage.root]["porttree"].dbapi.aux_get(cpv, ["IUSE"])[0].split()))
except:
return []
@rtype list
@returns [] or the list of IUSE flags
"""
- return VARDB.aux_get(cpv,[use])[0].split()
+ return portage.db[portage.root]["vartree"].dbapi.aux_get(cpv,[use])[0].split()
def reduce_flag(flag):
@return use, use_expand_hidden, usemask, useforce
"""
use = None
- PORTDB.settings.unlock()
+ portage.db[portage.root]["porttree"].dbapi.settings.unlock()
try:
- PORTDB.settings.setcpv(cpv, mydb=portage.portdb)
+ portage.db[portage.root]["porttree"].dbapi.settings.setcpv(cpv, mydb=portage.portdb)
use = portage.settings['PORTAGE_USE'].split()
use_expand_hidden = portage.settings["USE_EXPAND_HIDDEN"].split()
- usemask = list(PORTDB.settings.usemask)
- useforce = list(PORTDB.settings.useforce)
+ usemask = list(portage.db[portage.root]["porttree"].dbapi.settings.usemask)
+ useforce = list(portage.db[portage.root]["porttree"].dbapi.settings.useforce)
except KeyError:
- PORTDB.settings.reset()
- PORTDB.settings.lock()
+ portage.db[portage.root]["porttree"].dbapi.settings.reset()
+ portage.db[portage.root]["porttree"].dbapi.settings.lock()
return [], [], [], []
# reset cpv filter
- PORTDB.settings.reset()
- PORTDB.settings.lock()
+ portage.db[portage.root]["porttree"].dbapi.settings.reset()
+ portage.db[portage.root]["porttree"].dbapi.settings.lock()
return use, use_expand_hidden, usemask, useforce
from functools import partial
from itertools import chain
+import portage
+
from gentoolkit import pprinter as pp
from gentoolkit import errors
from gentoolkit.atom import Atom
from gentoolkit.cpv import CPV
-from gentoolkit.dbapi import BINDB, PORTDB, VARDB
from gentoolkit.versionmatch import VersionMatch
# This has to be imported below to stop circular import.
#from gentoolkit.package import Package
"""
if predicate:
- all_cps = iter(x for x in PORTDB.cp_all() if predicate(x))
+ all_cps = iter(x for x in portage.db[portage.root]["porttree"].dbapi.cp_all() if predicate(x))
else:
- all_cps = PORTDB.cp_all()
+ all_cps = portage.db[portage.root]["porttree"].dbapi.cp_all()
- all_cpvs = chain.from_iterable(PORTDB.cp_list(x) for x in all_cps)
+ all_cpvs = chain.from_iterable(portage.db[portage.root]["porttree"].dbapi.cp_list(x) for x in all_cps)
all_installed_cpvs = set(get_installed_cpvs(predicate))
if include_installed:
"""
if predicate:
- installed_cps = iter(x for x in VARDB.cp_all() if predicate(x))
+ installed_cps = iter(x for x in portage.db[portage.root]["vartree"].dbapi.cp_all() if predicate(x))
else:
- installed_cps = VARDB.cp_all()
+ installed_cps = portage.db[portage.root]["vartree"].dbapi.cp_all()
- for cpv in chain.from_iterable(VARDB.cp_list(x) for x in installed_cps):
+ for cpv in chain.from_iterable(portage.db[portage.root]["vartree"].dbapi.cp_list(x) for x in installed_cps):
yield cpv
"""
if predicate:
- installed_cps = iter(x for x in BINDB.cp_all() if predicate(x))
+ installed_cps = iter(x for x in portage.db[portage.root]["bintree"].dbapi.cp_all() if predicate(x))
else:
- installed_cps = BINDB.cp_all()
+ installed_cps = portage.db[portage.root]["bintree"].dbapi.cp_all()
- for cpv in chain.from_iterable(BINDB.cp_list(x) for x in installed_cps):
+ for cpv in chain.from_iterable(portage.db[portage.root]["bintree"].dbapi.cp_list(x) for x in installed_cps):
yield cpv
FORMAT_TMPL_VARS = (
'$location', '$mask', '$mask2', '$cp', '$cpv', '$category', '$name',
'$version', '$revision', '$fullversion', '$slot', '$repo', '$keywords'
-)
+)
# =======
# Imports
import gentoolkit.pprinter as pp
from gentoolkit import errors
from gentoolkit.cpv import CPV
-from gentoolkit.dbapi import PORTDB, VARDB
from gentoolkit.keyword import determine_keyword
from gentoolkit.flag import get_flags
from gentoolkit.eprefix import EPREFIX
envvars = (envvars,)
if prefer_vdb:
try:
- result = VARDB.aux_get(self.cpv, envvars)
+ result = portage.db[portage.root]["vartree"].dbapi.aux_get(self.cpv, envvars)
except KeyError:
try:
if not fallback:
raise KeyError
- result = PORTDB.aux_get(self.cpv, envvars)
+ result = portage.db[portage.root]["porttree"].dbapi.aux_get(self.cpv, envvars)
except KeyError:
err = "aux_get returned unexpected results"
raise errors.GentoolkitFatalError(err)
else:
try:
- result = PORTDB.aux_get(self.cpv, envvars)
+ result = portage.db[portage.root]["porttree"].dbapi.aux_get(self.cpv, envvars)
except KeyError:
try:
if not fallback:
raise KeyError
- result = VARDB.aux_get(self.cpv, envvars)
+ result = portage.db[portage.root]["vartree"].dbapi.aux_get(self.cpv, envvars)
except KeyError:
err = "aux_get returned unexpected results"
raise errors.GentoolkitFatalError(err)
def exists(self):
"""Return True if package exists in the Portage tree, else False"""
- return bool(PORTDB.cpv_exists(self.cpv))
+ return bool(portage.db[portage.root]["porttree"].dbapi.cpv_exists(self.cpv))
def settings(self, key):
"""Returns the value of the given key for this package (useful
try:
result = portage.getmaskingstatus(self.cpv,
settings=self._settings,
- portdb=PORTDB)
+ portdb=portage.db[portage.root]["porttree"].dbapi)
except KeyError:
# getmaskingstatus doesn't support packages without ebuilds in the
# Portage tree.
try:
result = portage.getmaskingreason(self.cpv,
settings=self._settings,
- portdb=PORTDB,
+ portdb=portage.db[portage.root]["porttree"].dbapi,
return_location=True)
if result is None:
result = tuple()
"""
if in_vartree:
- return VARDB.findname(self.cpv)
- return PORTDB.findname(self.cpv)
+ return portage.db[portage.root]["vartree"].dbapi.findname(self.cpv)
+ return portage.db[portage.root]["porttree"].dbapi.findname(self.cpv)
def package_path(self, in_vartree=False):
"""Return the path to where the ebuilds and other files reside."""
def is_overlay(self):
"""Returns True if the package is in an overlay."""
- ebuild, tree = PORTDB.findname2(self.cpv)
+ ebuild, tree = portage.db[portage.root]["porttree"].dbapi.findname2(self.cpv)
if not ebuild:
return None
if self._portdir_path is None:
@note: We blindly assume that the package actually exists on disk.
"""
- unmasked = PORTDB.xmatch("match-visible", self.cpv)
+ unmasked = portage.db[portage.root]["porttree"].dbapi.xmatch("match-visible", self.cpv)
return self.cpv not in unmasked
from gentoolkit import pprinter as pp
from gentoolkit.atom import Atom
from gentoolkit.cpv import CPV
-from gentoolkit.dbapi import PORTDB, VARDB
from gentoolkit.package import Package
from gentoolkit.sets import get_set_atoms, SETPREFIX
try:
if include_masked:
- matches = PORTDB.xmatch("match-all", self.query)
+ matches = portage.db[portage.root]["porttree"].dbapi.xmatch("match-all", self.query)
else:
- matches = PORTDB.match(self.query)
+ matches = portage.db[portage.root]["porttree"].dbapi.match(self.query)
if in_installed:
- matches.extend(VARDB.match(self.query))
+ matches.extend(portage.db[portage.root]["vartree"].dbapi.match(self.query))
except portage.exception.InvalidAtom as err:
message = "query.py: find(), query=%s, InvalidAtom=%s" %(
self.query, str(err))
"""Return a list of Package objects that matched the search key."""
try:
- matches = VARDB.match(self.query)
+ matches = portage.db[portage.root]["vartree"].dbapi.match(self.query)
# catch the ambiguous package Exception
except portage.exception.AmbiguousPackageName as err:
matches = []
for pkgkey in err.args[0]:
- matches.extend(VARDB.match(pkgkey))
+ matches.extend(portage.db[portage.root]["vartree"].dbapi.match(pkgkey))
except portage.exception.InvalidAtom as err:
raise errors.GentoolkitInvalidAtom(err)
best = keyworded = masked = None
try:
- best = PORTDB.xmatch("bestmatch-visible", self.query)
+ best = portage.db[portage.root]["porttree"].dbapi.xmatch("bestmatch-visible", self.query)
except portage.exception.InvalidAtom as err:
message = "query.py: find_best(), bestmatch-visible, " + \
"query=%s, InvalidAtom=%s" %(self.query, str(err))
if not (include_keyworded or include_masked):
return None
try:
- matches = PORTDB.xmatch("match-all", self.query)
+ matches = portage.db[portage.root]["porttree"].dbapi.xmatch("match-all", self.query)
except portage.exception.InvalidAtom as err:
message = "query.py: find_best(), match-all, query=%s, InvalidAtom=%s" %(
self.query, str(err))