(self)
| 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 = [] |
nothing calls this directly
no test coverage detected