forked from gee-community/geemap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
26 lines (22 loc) · 849 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Helpers for unit tests."""
def query_widget(node, type_matcher, matcher=None):
"""Recursively searches the widget hierarchy for the widget."""
if matcher is None:
matcher = lambda c: True
if hasattr(node, "layout"):
if hasattr(node.layout, "display"):
if node.layout.display == "none":
return None
if hasattr(node, "style"):
if hasattr(node.style, "display"):
if node.style.display == "none":
return None
children = getattr(node, "children", getattr(node, "nodes", None))
if children is not None:
for child in children:
result = query_widget(child, type_matcher, matcher)
if result:
return result
if isinstance(node, type_matcher) and matcher(node):
return node
return None