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/4420/head
parent
704c3815d3
commit
fa6ffa1dbd
|
@ -229,10 +229,13 @@ class Inventory(object):
|
||||||
def _match_one_pattern(self, pattern):
|
def _match_one_pattern(self, pattern):
|
||||||
"""
|
"""
|
||||||
Takes a single pattern (i.e., not "p1:p2") and returns a list of
|
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.
|
into account.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if pattern.startswith("&") or pattern.startswith("!"):
|
||||||
|
pattern = pattern[1:]
|
||||||
|
|
||||||
if pattern in self._pattern_cache:
|
if pattern in self._pattern_cache:
|
||||||
return self._pattern_cache[pattern]
|
return self._pattern_cache[pattern]
|
||||||
|
|
||||||
|
@ -308,9 +311,6 @@ class Inventory(object):
|
||||||
hosts = []
|
hosts = []
|
||||||
hostnames = set()
|
hostnames = set()
|
||||||
|
|
||||||
# ignore any negative checks here, this is handled elsewhere
|
|
||||||
pattern = pattern.replace("!","").replace("&", "")
|
|
||||||
|
|
||||||
def __append_host_to_results(host):
|
def __append_host_to_results(host):
|
||||||
if host.name not in hostnames:
|
if host.name not in hostnames:
|
||||||
hostnames.add(host.name)
|
hostnames.add(host.name)
|
||||||
|
|
Loading…
Reference in New Issue