def build_module(builder: Builder, lineno: int, token: str, nodes: typing.List[typing.Any]) -> bool: assert token == "module" for lineno, token, value in nodes: if token == "def ": builder.build_token(lineno, token, value) return True
def build_extends(builder: Builder, lineno: int, token: str, nodes: typing.List[typing.Any]) -> bool: assert token == "render" n = len(nodes) if not n: return False lineno, token, value = nodes[-1] if token != "extends": return False extends, nested = value if n > 1: nested = nodes[:-1] + nested for lineno, token, value in nested: if token in extends_tokens: builder.build_token(lineno, token, value) builder.add( builder.lineno + 1, "return _r(" + extends + ", ctx, local_defs, super_defs)", ) return True