def run(self, terms, variables=None, **kwargs): host_list = [] for term in terms: patterns = order_patterns(split_host_pattern(term)) for p in patterns: that = self.get_hosts(variables, p) if p.startswith("!"): host_list = [h for h in host_list if h not in that] elif p.startswith("&"): host_list = [h for h in host_list if h in that] else: host_list.extend(that) # return unique list return list(set(host_list))