Raise a specialized StringTree.Error rather than a bare Exception to
allow callers to distinguish where it came from.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit derives StringTree from Mapping, allowing it to be used
as a drop-in-replacement for dictionaries returned from load_yaml().
Note that this is a breaking change, because it changes the return
value of __getitem__() from str to StringTree. Either this or get()
have to give, because the base class uses __getitem__() to implement
get(), and returning different types from these, as it's currently
the case would break caller expectations.
To mitigate the pain of the breakage, __str__() now returns .content
or "", and can be used to easily convert []'s return value to a
string.
Signed-off-by: Jan Lindemann <jan@janware.com>
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>
Some methods take a "path_" argument, which is not nice for callers.
Rename it to "path" and fix the fallout in the method bodies.
Signed-off-by: Jan Lindemann <jan@janware.com>
Move all implementation source code from the jwutils module to
jw.util. For compatibility with existing Python modules, keep a thin,
autogenerated compatibility shim under jwutils.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-11 23:10:25 +00:00
Renamed from tools/python/jwutils/stree/StringTree.py (Previous history)