MCPcopy
hub / github.com/aosabook/500lines / _expr_code

Method _expr_code

template-engine/code/templite.py:197–213  ·  view source on GitHub ↗

Generate a Python expression for `expr`.

(self, expr)

Source from the content-addressed store, hash-verified

195 self._render_function = code.get_globals()['render_function']
196
197 def _expr_code(self, expr):
198 """Generate a Python expression for `expr`."""
199 if "|" in expr:
200 pipes = expr.split("|")
201 code = self._expr_code(pipes[0])
202 for func in pipes[1:]:
203 self._variable(func, self.all_vars)
204 code = "c_%s(%s)" % (func, code)
205 elif "." in expr:
206 dots = expr.split(".")
207 code = self._expr_code(dots[0])
208 args = ", ".join(repr(d) for d in dots[1:])
209 code = "do_dots(%s, %s)" % (code, args)
210 else:
211 self._variable(expr, self.all_vars)
212 code = "c_%s" % expr
213 return code
214
215 def _syntax_error(self, msg, thing):
216 """Raise a syntax error using `msg`, and showing `thing`."""

Callers 1

__init__Method · 0.95

Calls 2

_variableMethod · 0.95
joinMethod · 0.80

Tested by

no test coverage detected