scripts: edtlib: bindings_from_paths() helper function
This is a convenience function for creating a bunch of Binding objects from files in a directory. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
5d74da4681
commit
2c19cccd4b
@ -21,7 +21,8 @@ Each devicetree node (dtlib.Node) gets a corresponding edtlib.Node instance,
|
||||
which has all the information related to the node.
|
||||
|
||||
The top-level entry points for the library are the EDT and Binding classes.
|
||||
See their constructor docstrings for details.
|
||||
See their constructor docstrings for details. There is also a
|
||||
bindings_from_paths() helper function.
|
||||
"""
|
||||
|
||||
# NOTE: testedtlib.py is the test suite for this library.
|
||||
@ -1702,6 +1703,26 @@ class Binding:
|
||||
raise _err("can't _warn() outside of Binding.__init__")
|
||||
|
||||
|
||||
def bindings_from_paths(yaml_paths, ignore_errors=False):
|
||||
"""
|
||||
Get a list of Binding objects from the yaml files 'yaml_paths'.
|
||||
|
||||
If 'ignore_errors' is True, YAML files that cause an EDTError when
|
||||
loaded are ignored. (No other exception types are silenced.)
|
||||
"""
|
||||
|
||||
ret = []
|
||||
fname2path = {os.path.basename(path): path for path in yaml_paths}
|
||||
for path in yaml_paths:
|
||||
try:
|
||||
ret.append(Binding(path, fname2path))
|
||||
except EDTError:
|
||||
if ignore_errors:
|
||||
continue
|
||||
raise
|
||||
|
||||
return ret
|
||||
|
||||
class PropertySpec:
|
||||
"""
|
||||
Represents a "property specification", i.e. the description of a
|
||||
|
||||
Loading…
Reference in New Issue
Block a user