def get_wrappings(self, yield_func, items, max_count, expression, attributes, include_flattened=True): if len(items) == 1: yield_func(items[0]) else: if max_count is None or len(items) <= max_count: if 'Orderless' in attributes: for perm in permutations(items): sequence = Expression('Sequence', *perm) sequence.pattern_sequence = True yield_func(sequence) else: sequence = Expression('Sequence', *items) sequence.pattern_sequence = True yield_func(sequence) if 'Flat' in attributes and include_flattened: yield_func(Expression(expression.get_head(), *items))