Skip to content
ASDF Projects Tutorials Community
Back to top
View this page

# AsdfSearchResult

class asdf.search.AsdfSearchResult(identifiers, node, filters=None, parent_node=None, max_rows=24, max_cols=120, show_values=True)

  Bases: `object`

  Result of a call to AsdfFile.search.

  Attributes Summary

  `node` | Retrieve the leaf node of a tree with one search result.
  `nodes` | Retrieve all leaf nodes in the search results.
  `path` | Retrieve the path to the leaf node of a tree with one search result.
  `paths` | 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.
  `replace`(value) | Assign a new value in place of all leaf nodes in the search results.
  `schema_info`([key, preserve_list]) | Get a nested dictionary of the schema information for a given key, relative to this search result.
  `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)

    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

  replace(value)

    Assign a new value in place of all leaf nodes in the search results.

    Parameters:
      value object
  schema_info(key='description', preserve_list=True)

    Get a nested dictionary of the schema information for a given key, relative to this search result.

    Parameters:
      key str

        The key to look up. Default: “description”

      preserve_list bool

        If True, then lists are preserved. Otherwise, they are turned into dicts.

  search(key=NotSet, type_=NotSet, value=NotSet, filter_=None)

    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