AsdfSearchResult¶
-
class
asdf.search.
AsdfSearchResult
(identifiers, node, filters=[], parent_node=None, max_rows=24, max_cols=120, show_values=True)[source]¶ Bases:
object
Result of a call to AsdfFile.search.
Attributes Summary
Retrieve the leaf node of a tree with one search result.
Retrieve all leaf nodes in the search results.
Retrieve the path to the leaf node of a tree with one search result.
Retrieve the paths to all leaf nodes in the search results.
Methods Summary
format
([max_rows, max_cols, show_values])Change formatting parameters of the rendered tree.
search
([key, type, value, filter])Further narrow the search.
Attributes Documentation
-
node
¶ Retrieve the leaf node of a tree with one search result.
- Returns
object
the single node of the search result
-
nodes
¶ Retrieve all leaf nodes in the search results.
- Returns
list of object
every node in the search results (breadth-first order)
-
path
¶ Retrieve the path to the leaf node of a tree with one search result.
- Returns
str
the path to the searched node
-
paths
¶ Retrieve the paths to all leaf nodes in the search results.
- Returns
list of str
the path to every node in the search results
Methods Documentation
-
format
(max_rows=NotSet, max_cols=NotSet, show_values=NotSet)[source]¶ Change formatting parameters of the rendered tree.
- Parameters
max_rows : int, tuple, None, or NotSet, optional
Maximum number of lines to print. Nodes that cannot be displayed will be elided with a message. If int, constrain total number of displayed lines. If tuple, constrain lines per node at the depth corresponding to the tuple index. If None, display all lines. If NotSet, retain existing value.
max_cols : int, None or NotSet, optional
Maximum length of line to print. Nodes that cannot be fully displayed will be truncated with a message. If int, constrain length of displayed lines. If None, line length is unconstrained. If NotSet, retain existing value.
show_values : bool or NotSet, optional
Set to False to disable display of primitive values in the rendered tree. Set to NotSet to retain existign value.
- Returns
AsdfSearchResult
the reformatted search result
-
search
(key=NotSet, type=NotSet, value=NotSet, filter=None)[source]¶ Further narrow the search.
- Parameters
key : NotSet, str, or any other object
Search query that selects nodes by dict key or list index. If NotSet, the node key is unconstrained. If str, the input is searched among keys/indexes as a regular expression pattern. If any other object, node’s key or index must equal the queried key.
type : NotSet, str, or builtins.type
Search query that selects nodes by type. If NotSet, the node type is unconstrained. If str, the input is searched among (fully qualified) node type names as a regular expression pattern. If builtins.type, the node must be an instance of the input.
value : NotSet, str, or any other object
Search query that selects nodes by value. If NotSet, the node value is unconstrained. If str, the input is searched among values as a regular expression pattern. If any other object, node’s value must equal the queried value.
filter : callable
Callable that filters nodes by arbitrary criteria. The callable accepts one or two arguments:
the node
the node’s list index or dict key (optional)
and returns True to retain the node, or False to remove it from the search results.
- Returns
AsdfSearchResult
the subsequent search result
-