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

Method parse_statements

module/lib/jinja2/parser.py:141–166  ·  view source on GitHub ↗

Parse multiple statements into a list until one of the end tokens is reached. This is used to parse the body of statements as it also parses template data if appropriate. The parser checks first if the current token is a colon and skips it if there is one. Then it checks

(self, end_tokens, drop_needle=False)

Source from the content-addressed store, hash-verified

139 self._tag_stack.pop()
140
141 def parse_statements(self, end_tokens, drop_needle=False):
142 """Parse multiple statements into a list until one of the end tokens
143 is reached. This is used to parse the body of statements as it also
144 parses template data if appropriate. The parser checks first if the
145 current token is a colon and skips it if there is one. Then it checks
146 for the block end and parses until if one of the `end_tokens` is
147 reached. Per default the active token in the stream at the end of
148 the call is the matched end token. If this is not wanted `drop_needle`
149 can be set to `True` and the end token is removed.
150 """
151 # the first token may be a colon for python compatibility
152 self.stream.skip_if('colon')
153
154 # in the future it would be possible to add whole code sections
155 # by adding some sort of end of statement token and parsing those here.
156 self.stream.expect('block_end')
157 result = self.subparse(end_tokens)
158
159 # we reached the end of the template too early, the subparser
160 # does not check for this, so we do that now
161 if self.stream.current.type == 'eof':
162 self.fail_eof(end_tokens)
163
164 if drop_needle:
165 next(self.stream)
166 return result
167
168 def parse_set(self):
169 """Parse an assign statement."""

Callers 8

parse_forMethod · 0.95
parse_ifMethod · 0.95
parse_blockMethod · 0.95
parse_call_blockMethod · 0.95
parse_filter_blockMethod · 0.95
parse_macroMethod · 0.95
parseMethod · 0.80
parseMethod · 0.80

Calls 5

subparseMethod · 0.95
fail_eofMethod · 0.95
nextFunction · 0.90
skip_ifMethod · 0.80
expectMethod · 0.80

Tested by

no test coverage detected