def run(self, terms, variables=None, **kwargs): terms = self._lookup_variables(terms) my_list = terms[:] if len(my_list) == 0: raise AnsibleError("with_together requires at least one element in each list") return [self._flatten(x) for x in zip_longest(*my_list, fillvalue=None)]
def run(self, terms, variables=None, **kwargs): terms = self._lookup_variables(terms) my_list = terms[:] if len(my_list) == 0: raise AnsibleError( "with_together requires at least one element in each list") return [ self._flatten(x) for x in zip_longest(*my_list, fillvalue=None) ]
def merge(one, two): ''' Merge two complex nested datastructures into one''' if isinstance(one, dict) and isinstance(two, dict): copy = dict(one) # copy.update({key: merge(one.get(key, None), two[key]) for key in two}) copy.update( dict((key, merge(one.get(key, None), two[key])) for key in two)) return copy elif isinstance(one, list) and isinstance(two, list): return [merge(alpha, beta) for (alpha, beta) in zip_longest(one, two)] return one if two is None else two
def get_next(iterable): item, next_item = itertools.tee(iterable, 2) next_item = itertools.islice(next_item, 1, None) return zip_longest(item, next_item)
def get_next(iterable): item, next_item = itertools.tee(iterable, 2) next_item = itertools.islice(next_item, 1, None) warnings.append('ignorning unnecessary argument replace') return zip_longest(item, next_item)
def get_next(iterable): item, next_item = itertools.tee(iterable, 2) next_item = itertools.islice(next_item, 1, None) return zip_longest(item, next_item)