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

Method parse_from

tools/inspector_protocol/jinja2/parser.py:304–340  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

302 return self.parse_import_context(node, False)
303
304 def parse_from(self):
305 node = nodes.FromImport(lineno=next(self.stream).lineno)
306 node.template = self.parse_expression()
307 self.stream.expect('name:import')
308 node.names = []
309
310 def parse_context():
311 if self.stream.current.value in ('with', 'without') and \
312 self.stream.look().test('name:context'):
313 node.with_context = next(self.stream).value == 'with'
314 self.stream.skip()
315 return True
316 return False
317
318 while 1:
319 if node.names:
320 self.stream.expect('comma')
321 if self.stream.current.type == 'name':
322 if parse_context():
323 break
324 target = self.parse_assign_target(name_only=True)
325 if target.name.startswith('_'):
326 self.fail('names starting with an underline can not '
327 'be imported', target.lineno,
328 exc=TemplateAssertionError)
329 if self.stream.skip_if('name:as'):
330 alias = self.parse_assign_target(name_only=True)
331 node.names.append((target.name, alias.name))
332 else:
333 node.names.append(target.name)
334 if parse_context() or self.stream.current.type != 'comma':
335 break
336 else:
337 self.stream.expect('name')
338 if not hasattr(node, 'with_context'):
339 node.with_context = False
340 return node
341
342 def parse_signature(self, node):
343 node.args = 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