def iter_python_expressions(self, expr): """Iterates over translatable python expressions in a TALES expression. Yields each Python expression in the TALES expression that has an underscore call in it. """ if not UNDERSCORE_CALL.search(expr): # Short-circuit when there's nothing we're interested in raise StopIteration for part in split_parts.split(expr): part = part.strip() prefix = match_prefix(part) if prefix is not None: part = part[len(prefix.group(0)):] elif part.startswith('structure '): # Backwards compatibility for structure as a keyword part = part[10:] if UNDERSCORE_CALL.search(part): yield part
def split_expression(source, default_engine): for part in split_parts.split(source): expression = part.strip().replace("\\|", "|") yield get_tales_engine(expression, default_engine)
def split_expression(source, default_engine): for part in split_parts.split(source): expression = part.strip().replace('\\|', '|') yield get_tales_engine(expression, default_engine)