nodes: add helper function to retrieve the pretty-printed node as a string
This commit is contained in:
parent
e28b1ef802
commit
89a9bb7901
1 changed files with 4 additions and 1 deletions
|
|
@ -45,7 +45,10 @@ class Node:
|
||||||
return f"{self.__class__.__name__}({vals})"
|
return f"{self.__class__.__name__}({vals})"
|
||||||
|
|
||||||
def pprint(self, depth: int | None = None, indent: str = "\t"):
|
def pprint(self, depth: int | None = None, indent: str = "\t"):
|
||||||
print("\n".join(self._pprint(depth=depth, indent=indent)))
|
print(self._pretty(depth, indent))
|
||||||
|
|
||||||
|
def _pretty(self, depth: int | None = None, indent: str = "\t") -> str:
|
||||||
|
return "\n".join(self._pprint(depth=depth, indent=indent))
|
||||||
|
|
||||||
def _pprint(self, depth: int | None, indent: str, _depth: int = 0) -> list[str]:
|
def _pprint(self, depth: int | None, indent: str, _depth: int = 0) -> list[str]:
|
||||||
if depth is not None and _depth >= depth:
|
if depth is not None and _depth >= depth:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue