stree.StringTree.read(): Add classmethod

Add StringTree.read() which is a frontend for serdes.read(), saving
one import from the caller's perspective.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-07-02 11:00:58 +02:00 • committed by janware DevOps
commit b26e709082
Signed by: DevOps
SSH key fingerprint: SHA256:cZiw7ExG5q3KAVm7Jse3rGITowu0VjgUgNMPbifmY8g

View file

@ -351,10 +351,26 @@ class StringTree: # export
val: str | None = None,
match: Match = Match.Equal,
depth_first: bool = False
):
) -> list[str]:
ret: list[str] = []
for node in self.__find(key, val, m = match, depth_first = depth_first):
if node.parent is None:
break
ret.append(node.parent.path)
return ret
@classmethod
def read(
cls,
path: str,
root_content: str = 'root',
log_prio = INFO,
paths_buf = None
) -> StringTree:
from .serdes import read
return read(
path,
root_content = root_content,
log_prio = log_prio,
paths_buf = paths_buf
)