Remove & and ! pattern prefixes as early as possible

Now everything under _match_one_pattern can ignore them. This also means
that we can use the cache to return the same results for 'foo' and '!foo'.
pull/12057/head
Abhijit Menon-Sen 9 years ago
parent 704c3815d3
commit fa6ffa1dbd

@ -229,10 +229,13 @@ class Inventory(object):
def _match_one_pattern(self, pattern):
"""
Takes a single pattern (i.e., not "p1:p2") and returns a list of
matching hosts names. Does not take negatives or intersections
matching host names. Does not take negatives or intersections
into account.
"""
if pattern.startswith("&") or pattern.startswith("!"):
pattern = pattern[1:]
if pattern in self._pattern_cache:
return self._pattern_cache[pattern]
@ -308,9 +311,6 @@ class Inventory(object):
hosts = []
hostnames = set()
# ignore any negative checks here, this is handled elsewhere
pattern = pattern.replace("!","").replace("&", "")
def __append_host_to_results(host):
if host.name not in hostnames:
hostnames.add(host.name)

Loading…
Cancel
Save