[equo] implement the "--injected" switch for "equo match"

This commit is contained in:
Fabio Erculiani
2012-12-08 12:57:44 +01:00
parent 74f774e796
commit f2cf417979

View File

@@ -40,6 +40,7 @@ Match package names.
self._quiet = False
self._verbose = False
self._installed = False
self._injected = False
self._available = False
self._multimatch = False
self._multirepo = False
@@ -60,7 +61,7 @@ Match package names.
"""
args = [
"--quiet", "-q", "--verbose", "-v",
"--installed", "--available",
"--installed", "--injected", "--available",
"--multimatch", "--multirepo",
"--showrepo", "--showslot"]
args.sort()
@@ -88,6 +89,10 @@ Match package names.
default=self._verbose,
help=_('verbose output'))
parser.add_argument("--injected", action="store_true",
default=self._injected,
help=_('return only injected packages '))
group = parser.add_mutually_exclusive_group()
group.add_argument("--installed", action="store_true",
default=self._installed,
@@ -170,14 +175,25 @@ Match package names.
multi_repo = self._multirepo,
mask_filter = False)
# filter functions
is_injected = lambda (x, y): entropy_client.open_repository(
y).isInjected(x)
_matches = []
if match[1] != 1:
if not self._multimatch:
if self._multirepo:
matches += match[0]
_matches += match[0]
else:
matches += [match]
_matches += [match]
else:
matches += match[0]
_matches += match[0]
# apply filters
if self._injected:
_matches = filter(is_injected, _matches)
matches.extend(_matches)
key_sorter = lambda x: \
entropy_client.open_repository(x[1]).retrieveAtom(x[0])