示例#1
0
文件: xml.py 项目: dokai/lingua
    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
示例#2
0
文件: xml.py 项目: wichert/lingua
def split_expression(source, default_engine):
    for part in split_parts.split(source):
        expression = part.strip().replace("\\|", "|")
        yield get_tales_engine(expression, default_engine)
示例#3
0
文件: xml.py 项目: tanakapayam/lingua
def split_expression(source, default_engine):
    for part in split_parts.split(source):
        expression = part.strip().replace('\\|', '|')
        yield get_tales_engine(expression, default_engine)