MCPcopy Index your code
hub / github.com/pyload/pyload / parse_assign_target

Method parse_assign_target

module/lib/jinja2/parser.py:356–378  ·  view source on GitHub ↗

Parse an assignment target. As Jinja2 allows assignments to tuples, this function can parse all allowed assignment targets. Per default assignments to tuples are parsed, that can be disable however by setting `with_tuple` to `False`. If only assignments to names are

(self, with_tuple=True, name_only=False,
                            extra_end_rules=None)

Source from the content-addressed store, hash-verified

354 return node
355
356 def parse_assign_target(self, with_tuple=True, name_only=False,
357 extra_end_rules=None):
358 """Parse an assignment target. As Jinja2 allows assignments to
359 tuples, this function can parse all allowed assignment targets. Per
360 default assignments to tuples are parsed, that can be disable however
361 by setting `with_tuple` to `False`. If only assignments to names are
362 wanted `name_only` can be set to `True`. The `extra_end_rules`
363 parameter is forwarded to the tuple parsing function.
364 """
365 if name_only:
366 token = self.stream.expect('name')
367 target = nodes.Name(token.value, 'store', lineno=token.lineno)
368 else:
369 if with_tuple:
370 target = self.parse_tuple(simplified=True,
371 extra_end_rules=extra_end_rules)
372 else:
373 target = self.parse_primary()
374 target.set_ctx('store')
375 if not target.can_assign():
376 self.fail('can\'t assign to %r' % target.__class__.
377 __name__.lower(), target.lineno)
378 return target
379
380 def parse_expression(self, with_condexpr=True):
381 """Parse an expression. Per default all expressions are parsed, if

Callers 7

parse_setMethod · 0.95
parse_forMethod · 0.95
parse_importMethod · 0.95
parse_fromMethod · 0.95
parse_signatureMethod · 0.95
parse_macroMethod · 0.95
parseMethod · 0.80

Calls 6

parse_tupleMethod · 0.95
parse_primaryMethod · 0.95
can_assignMethod · 0.95
failMethod · 0.95
expectMethod · 0.80
set_ctxMethod · 0.80

Tested by

no test coverage detected