MCPcopy
hub / github.com/Textualize/rich / expand

Method expand

rich/pretty.py:519–550  ·  view source on GitHub ↗

Expand this line by adding children on their own line.

(self, indent_size: int)

Source from the content-addressed store, hash-verified

517 return self.node.check_length(start_length, max_length)
518
519 def expand(self, indent_size: int) -> Iterable["_Line"]:
520 """Expand this line by adding children on their own line."""
521 node = self.node
522 assert node is not None
523 whitespace = self.whitespace
524 assert node.children
525 if node.key_repr:
526 new_line = yield _Line(
527 text=f"{node.key_repr}{node.key_separator}{node.open_brace}",
528 whitespace=whitespace,
529 )
530 else:
531 new_line = yield _Line(text=node.open_brace, whitespace=whitespace)
532 child_whitespace = self.whitespace + " " * indent_size
533 tuple_of_one = node.is_tuple and len(node.children) == 1
534 for last, child in loop_last(node.children):
535 separator = "," if tuple_of_one else node.separator
536 line = _Line(
537 parent=new_line,
538 node=child,
539 whitespace=child_whitespace,
540 suffix=separator,
541 last=last and not tuple_of_one,
542 )
543 yield line
544
545 yield _Line(
546 text=node.close_brace,
547 whitespace=whitespace,
548 suffix=self.suffix,
549 last=self.last,
550 )
551
552 def __str__(self) -> str:
553 if self.last:

Callers 1

renderMethod · 0.45

Calls 2

_LineClass · 0.85
loop_lastFunction · 0.85

Tested by

no test coverage detected