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:
parent
aec0b0a3f5
commit
b26e709082
1 changed files with 17 additions and 1 deletions
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue