# public interface
#
def __init__(self, settings, portdb, vartree, spinner, searchdesc,
- verbose):
+ verbose, setconfig):
"""Searches the available and installed packages for the supplied search key.
The list of available and installed packages is created at object instantiation.
This makes successive searches faster."""
self.spinner = spinner
self.verbose = verbose
self.searchdesc = searchdesc
+ self.setconfig = setconfig
def execute(self,searchkey):
"""Performs the search for the supplied search key"""
self.packagematches = []
if self.searchdesc:
self.searchdesc=1
- self.matches = {"pkg":[], "desc":[]}
+ self.matches = {"pkg":[], "desc":[], "set":[]}
else:
self.searchdesc=0
- self.matches = {"pkg":[]}
+ self.matches = {"pkg":[], "set":[]}
print "Searching... ",
regexsearch = False
continue
if self.searchre.search(full_desc):
self.matches["desc"].append([full_package,masked])
+
+ self.sdict = self.setconfig.getSets()[0]
+ for setname in self.sdict:
+ self.spinner.update()
+ if match_category:
+ match_string = setname
+ else:
+ match_string = setname.split("/")[-1]
+
+ if self.searchre.search(match_string):
+ self.matches["set"].append([setname, False])
+ elif self.searchdesc:
+ if self.searchre.search(sdict[setname].getMetadata("DESCRIPTION")):
+ self.matches["set"].append([setname, False])
+
self.mlen=0
for mtype in self.matches:
self.matches[mtype].sort()
print " "
for mtype in self.matches:
for match,masked in self.matches[mtype]:
- if mtype=="pkg":
- catpack=match
+ full_package = None
+ if mtype == "pkg":
+ catpack = match
full_package = self.portdb.xmatch(
"bestmatch-visible", match)
if not full_package:
masked=1
full_package = portage.best(
self.portdb.xmatch("match-all",match))
- else:
+ elif mtype == "desc":
full_package = match
match = portage.pkgsplit(match)[0]
-
+ elif mtype == "set":
+ print green("*")+" "+white(match)
+ print " ", darkgreen("Description:")+" ", self.sdict[match].getMetadata("DESCRIPTION")
+ print
if full_package:
try:
desc, homepage, license = self.portdb.aux_get(
mydbapi=trees[settings["ROOT"]]["vartree"].dbapi,
tree="vartree")
-def action_search(settings, portdb, vartree, myopts, myfiles, spinner):
+def action_search(settings, portdb, vartree, myopts, myfiles, spinner, setconfig):
if not myfiles:
print "emerge: no search terms provided."
else:
searchinstance = search(settings, portdb,
vartree, spinner, "--searchdesc" in myopts,
- "--quiet" not in myopts)
+ "--quiet" not in myopts, setconfig)
for mysearch in myfiles:
try:
searchinstance.execute(mysearch)
print colorize("BAD", "\n*** emerging by path is broken and may not always work!!!\n")
break
+ setconfigpaths = ["/usr/share/portage/config/sets.conf", os.path.join(settings["PORTDIR"], "sets.conf"), \
+ os.path.join(os.sep, settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "sets.conf")]
+ #setconfig = SetConfig(setconfigpaths, settings, trees[settings["ROOT"]])
+ setconfig = make_default_config(settings, trees[settings["ROOT"]])
+ del setconfigpaths
if myaction not in ["search", "metadata", "sync"]:
- setconfigpaths = ["/usr/share/portage/config/sets.conf", os.path.join(settings["PORTDIR"], "sets.conf"), \
- os.path.join(os.sep, settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "sets.conf")]
- #setconfig = SetConfig(setconfigpaths, settings, trees[settings["ROOT"]])
- setconfig = make_default_config(settings, trees[settings["ROOT"]])
- del setconfigpaths
packagesets, setconfig_errors = setconfig.getSetsWithAliases()
for s in packagesets:
if s in myfiles:
elif "search"==myaction:
validate_ebuild_environment(trees)
action_search(settings, portdb, trees["/"]["vartree"],
- myopts, myfiles, spinner)
+ myopts, myfiles, spinner, setconfig)
elif myaction in ("clean", "unmerge") or \
(myaction == "prune" and "--nodeps" in myopts):
validate_ebuild_environment(trees)