On 01/09/2025 1:31 pm, Ayan Kumar Halder wrote:
> diff --git a/scripts/dt_sanity.py b/scripts/dt_sanity.py
> new file mode 100644
> index 0000000..171947f
> --- /dev/null
> +++ b/scripts/dt_sanity.py
> @@ -0,0 +1,33 @@
Shebang
> +import argparse
> +from pydevicetree import Devicetree
pydevicetree isn't part of the standard library. Readme should note the
external dependency. Also it should be separate from stdlib imports.
> sys
> +
> +def load_compatible_strings(config_path):
> + with open(config_path, 'r') as file:
> + return [line.strip() for line in file if line.strip()]
You should choose a different name from file as it shadows a keyword.
Also, you want something more like this
with open() as f:
for l in f.readlines():
l.strip()
if l:
yield l
but you really ought to also consider supporting comments in this config
file.
> +
> +def check_compatible_nodes(dts_path):
> + # Parse the DTS file
> + tree = Devicetree.parseFile(dts_path)
> +
> + # Search nodes for compatible properties in the global array
> + for compatible in compatible_strings:
> + nodes = tree.match(compatible)
> + if len(nodes) == 0:
if not nodes:
> + print(f"Error: Node with compatible '{compatible}' not found.")
f-strings are not supported in our minimum version of python. Use % or
.format().
~Andrew