MCPcopy Index your code
hub / github.com/nodejs/node / parse_from

Method parse_from

deps/v8/third_party/jinja2/parser.py:360–400  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

358 return self.parse_import_context(node, False)
359
360 def parse_from(self) -> nodes.FromImport:
361 node = nodes.FromImport(lineno=next(self.stream).lineno)
362 node.template = self.parse_expression()
363 self.stream.expect("name:import")
364 node.names = []
365
366 def parse_context() -> bool:
367 if self.stream.current.value in {
368 "with",
369 "without",
370 } and self.stream.look().test("name:context"):
371 node.with_context = next(self.stream).value == "with"
372 self.stream.skip()
373 return True
374 return False
375
376 while True:
377 if node.names:
378 self.stream.expect("comma")
379 if self.stream.current.type == "name":
380 if parse_context():
381 break
382 target = self.parse_assign_target(name_only=True)
383 if target.name.startswith("_"):
384 self.fail(
385 "names starting with an underline can not be imported",
386 target.lineno,
387 exc=TemplateAssertionError,
388 )
389 if self.stream.skip_if("name:as"):
390 alias = self.parse_assign_target(name_only=True)
391 node.names.append((target.name, alias.name))
392 else:
393 node.names.append(target.name)
394 if parse_context() or self.stream.current.type != "comma":
395 break
396 else:
397 self.stream.expect("name")
398 if not hasattr(node, "with_context"):
399 node.with_context = False
400 return node
401
402 def parse_signature(self, node: _MacroCall) -> None:
403 args = node.args = []

Callers

nothing calls this directly

Calls 7

parse_expressionMethod · 0.95
parse_assign_targetMethod · 0.95
failMethod · 0.95
nextFunction · 0.50
expectMethod · 0.45
skip_ifMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected