MCPcopy
hub / github.com/pallets/jinja / set_ctx

Method set_ctx

src/jinja2/nodes.py:206–218  ·  view source on GitHub ↗

Reset the context of a node and all child nodes. Per default the parser will all generate nodes that have a 'load' context as it's the most common one. This method is used in the parser to set assignment targets and other nodes to a store context.

(self, ctx: str)

Source from the content-addressed store, hash-verified

204 yield from child.find_all(node_type)
205
206 def set_ctx(self, ctx: str) -> "Node":
207 """Reset the context of a node and all child nodes. Per default the
208 parser will all generate nodes that have a 'load' context as it's the
209 most common one. This method is used in the parser to set assignment
210 targets and other nodes to a store context.
211 """
212 todo = deque([self])
213 while todo:
214 node = todo.popleft()
215 if "ctx" in node.fields:
216 node.ctx = ctx # type: ignore
217 todo.extend(node.iter_child_nodes())
218 return self
219
220 def set_lineno(self, lineno: int, override: bool = False) -> "Node":
221 """Set the line numbers of the node and children."""

Callers 3

parse_withMethod · 0.80
parse_signatureMethod · 0.80
parse_assign_targetMethod · 0.80

Calls 2

extendMethod · 0.80
iter_child_nodesMethod · 0.80

Tested by

no test coverage detected