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

Method parse_from

module/lib/jinja2/parser.py:265–302  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

263 return self.parse_import_context(node, False)
264
265 def parse_from(self):
266 node = nodes.FromImport(lineno=next(self.stream).lineno)
267 node.template = self.parse_expression()
268 self.stream.expect('name:import')
269 node.names = []
270
271 def parse_context():
272 if self.stream.current.value in ('with', 'without') and \
273 self.stream.look().test('name:context'):
274 node.with_context = next(self.stream).value == 'with'
275 self.stream.skip()
276 return True
277 return False
278
279 while 1:
280 if node.names:
281 self.stream.expect('comma')
282 if self.stream.current.type == 'name':
283 if parse_context():
284 break
285 target = self.parse_assign_target(name_only=True)
286 if target.name.startswith('_'):
287 self.fail('names starting with an underline can not '
288 'be imported', target.lineno,
289 exc=TemplateAssertionError)
290 if self.stream.skip_if('name:as'):
291 alias = self.parse_assign_target(name_only=True)
292 node.names.append((target.name, alias.name))
293 else:
294 node.names.append(target.name)
295 if parse_context() or self.stream.current.type != 'comma':
296 break
297 else:
298 break
299 if not hasattr(node, 'with_context'):
300 node.with_context = False
301 self.stream.skip_if('comma')
302 return node
303
304 def parse_signature(self, node):
305 node.args = args = []

Callers

nothing calls this directly

Calls 7

parse_expressionMethod · 0.95
parse_assign_targetMethod · 0.95
failMethod · 0.95
nextFunction · 0.90
expectMethod · 0.80
skip_ifMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected