On Fri, Nov 06, 2026 at 06:43:18PM -0800, Doug Anderson wrote: > Hi Simon, > > On Wed, Nov 4, 2026 at 6:08 AM Simon Glass wrote: > > > > Hi Doug, > > > > On Sun, Nov 1, 2026 at 4:02 PM Douglas Anderson wrote: > > > > > > Add `devicetree.py` providing `DeviceTree`, a non-flattened in-memory > > > representation of a devicetree node and its subtree: > > > > Please can you start with the motivation, i.e. why a live tree is > > needed and what will use it? The list below mostly repeats the > > docstrings. > > Makes sense. In my draft v4 I've updated the commit message to lead > with the motivation and condensed the summary so it doesn't repeat the > docstrings: > > `pylibfdt`'s `Fdt` and `FdtRo` classes operate directly on flattened > device tree blobs, where inserting or deleting nodes and properties > shifts subsequent node offsets. That works well for in-place queries and > localized edits, but makes multi-tree comparison, structural diffing, > and bottom-up tree construction (as needed by the upcoming `fdtfactor` > tool) awkward and error-prone. > > Add `pylibfdt/devicetree.py` providing `DeviceTree`, an in-memory live > tree representation where each node holds `props` (a dict mapping > property name to `libfdt.Property`) and `children` (a dict mapping child > node name to child `DeviceTree`), along with `unflatten()` and > `flatten()` to convert between `FdtRo`/`Fdt` blobs and live trees, and > helpers for path lookup, node creation, and pre-order traversal. > > Add unit tests in `tests/devicetree_tests.py` covering `DeviceTree` > round-tripping, subtree unflattening, duplicate-name and corrupt-tree > rejection, and navigation helpers. > > > > diff --git a/devicetree.py b/devicetree.py > > > new file mode 100644 > > > index 0000000..f81b8fc > > > --- /dev/null > > > +++ b/devicetree.py > > > @@ -0,0 +1,226 @@ > > > +# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) > > > +"""devicetree - Non-flattened in-memory device tree representation in Python.""" > > > > I'd forgotten about this but PyPI has Zephyr's python-devicetree > > [1][2], which installs a top-level 'devicetree' package. > > > > I'm not sure what to suggest. Would libfdt_devicetree be too awful? > > Right. I'm OK with libfdt_devicetree. David: do you have any > objections? Don't love it, but can't quickly think of a better option. -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson