Writes a function call to the stream for the current node. A leading comma is added automatically. The extra keyword arguments may not include python keywords otherwise a syntax error could occour. The extra keyword arguments should be given as python dict.
(self, node, frame, extra_kwargs=None)
| 407 | self._last_line = node.lineno |
| 408 | |
| 409 | def signature(self, node, frame, extra_kwargs=None): |
| 410 | """Writes a function call to the stream for the current node. |
| 411 | A leading comma is added automatically. The extra keyword |
| 412 | arguments may not include python keywords otherwise a syntax |
| 413 | error could occour. The extra keyword arguments should be given |
| 414 | as python dict. |
| 415 | """ |
| 416 | # if any of the given keyword arguments is a python keyword |
| 417 | # we have to make sure that no invalid call is created. |
| 418 | kwarg_workaround = False |
| 419 | for kwarg in chain((x.key for x in node.kwargs), extra_kwargs or ()): |
| 420 | if is_python_keyword(kwarg): |
| 421 | kwarg_workaround = True |
| 422 | break |
| 423 | |
| 424 | for arg in node.args: |
| 425 | self.write(', ') |
| 426 | self.visit(arg, frame) |
| 427 | |
| 428 | if not kwarg_workaround: |
| 429 | for kwarg in node.kwargs: |
| 430 | self.write(', ') |
| 431 | self.visit(kwarg, frame) |
| 432 | if extra_kwargs is not None: |
| 433 | for key, value in iteritems(extra_kwargs): |
| 434 | self.write(', %s=%s' % (key, value)) |
| 435 | if node.dyn_args: |
| 436 | self.write(', *') |
| 437 | self.visit(node.dyn_args, frame) |
| 438 | |
| 439 | if kwarg_workaround: |
| 440 | if node.dyn_kwargs is not None: |
| 441 | self.write(', **dict({') |
| 442 | else: |
| 443 | self.write(', **{') |
| 444 | for kwarg in node.kwargs: |
| 445 | self.write('%r: ' % kwarg.key) |
| 446 | self.visit(kwarg.value, frame) |
| 447 | self.write(', ') |
| 448 | if extra_kwargs is not None: |
| 449 | for key, value in iteritems(extra_kwargs): |
| 450 | self.write('%r: %s, ' % (key, value)) |
| 451 | if node.dyn_kwargs is not None: |
| 452 | self.write('}, **') |
| 453 | self.visit(node.dyn_kwargs, frame) |
| 454 | self.write(')') |
| 455 | else: |
| 456 | self.write('}') |
| 457 | |
| 458 | elif node.dyn_kwargs is not None: |
| 459 | self.write(', **') |
| 460 | self.visit(node.dyn_kwargs, frame) |
| 461 | |
| 462 | def pull_dependencies(self, nodes): |
| 463 | """Pull all the dependencies.""" |
no test coverage detected