Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pydevicetree/ast/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,14 @@ def filter(self, matchFunc: MatchFunc, cbFunc: MatchCallback = None) -> List['No

return nodes

def match(self, compatible: Pattern, func: MatchCallback = None) -> List['Node']:
def match(self, compatible: Pattern | str, func: MatchCallback = None) -> List['Node']:
"""Get a node from the subtree by compatible string

Accepts a regular expression to match one of the strings in the compatible property.
"""
regex = re.compile(compatible)
regex = compatible
if isinstance(regex, str):
regex = re.compile(regex)

def match_compat(node: Node) -> bool:
compatibles = node.get_fields("compatible")
Expand Down
Loading