A dict used in a call_ex_kw2, which are a dictionary items expressed in a call. This should format to: a=1, b=2 In other words, no braces, no quotes around keys and ":" becomes "=". We will source-code use line breaks to guide us when to break.
(node)
| 427 | self.call36_tuple = call36_tuple |
| 428 | |
| 429 | def call36_dict(node): |
| 430 | """ |
| 431 | A dict used in a call_ex_kw2, which are a dictionary items expressed |
| 432 | in a call. This should format to: |
| 433 | a=1, b=2 |
| 434 | In other words, no braces, no quotes around keys and ":" becomes |
| 435 | "=". |
| 436 | |
| 437 | We will source-code use line breaks to guide us when to break. |
| 438 | """ |
| 439 | p = self.prec |
| 440 | self.prec = 100 |
| 441 | |
| 442 | self.indent_more(INDENT_PER_LEVEL) |
| 443 | sep = INDENT_PER_LEVEL[:-1] |
| 444 | line_number = self.line_number |
| 445 | |
| 446 | if node[0].kind.startswith("kvlist"): |
| 447 | # Python 3.5+ style key/value list in dict |
| 448 | kv_node = node[0] |
| 449 | l = list(kv_node) |
| 450 | i = 0 |
| 451 | |
| 452 | length = len(l) |
| 453 | # FIXME: Parser-speed improved grammars will have BUILD_MAP |
| 454 | # at the end. So in the future when everything is |
| 455 | # complete, we can do an "assert" instead of "if". |
| 456 | if kv_node[-1].kind.startswith("BUILD_MAP"): |
| 457 | length -= 1 |
| 458 | |
| 459 | # Respect line breaks from source |
| 460 | while i < length: |
| 461 | self.write(sep) |
| 462 | name = self.traverse(l[i], indent="") |
| 463 | # Strip off beginning and trailing quotes in name |
| 464 | name = name[1:-1] |
| 465 | if i > 0: |
| 466 | line_number = self.indent_if_source_nl( |
| 467 | line_number, self.indent + INDENT_PER_LEVEL[:-1] |
| 468 | ) |
| 469 | line_number = self.line_number |
| 470 | self.write(name, "=") |
| 471 | value = self.traverse( |
| 472 | l[i + 1], indent=self.indent + (len(name) + 2) * " " |
| 473 | ) |
| 474 | self.write(value) |
| 475 | sep = ", " |
| 476 | if line_number != self.line_number: |
| 477 | sep += "\n" + self.indent + INDENT_PER_LEVEL[:-1] |
| 478 | line_number = self.line_number |
| 479 | i += 2 |
| 480 | pass |
| 481 | elif node[-1].kind.startswith("BUILD_CONST_KEY_MAP"): |
| 482 | keys_node = node[-2] |
| 483 | keys = keys_node.attr |
| 484 | # from trepan.api import debug; debug() |
| 485 | assert keys_node == "LOAD_CONST" and isinstance(keys, tuple) |
| 486 | for i in range(node[-1].attr): |
nothing calls this directly
no test coverage detected