agrifoodpy.utils.dict_utils =========================== .. py:module:: agrifoodpy.utils.dict_utils .. autoapi-nested-parse:: Pipeline utilities Functions --------- .. autoapisummary:: agrifoodpy.utils.dict_utils.item_parser agrifoodpy.utils.dict_utils.get_dict agrifoodpy.utils.dict_utils.set_dict Module Contents --------------- .. py:function:: item_parser(fbs, items) Extracts a list of items from a dataset using a coordinate-key tuple, or converts a scalar item to a list :param fbs: The dataset containing the coordinate-key to extract items from. :type fbs: xarray.Dataset or xarray.DataArray :param items: If a tuple, the first element is the name of the coordinate and the second element is a list of items to extract. If a scalar, the item is converted to a list. :type items: tuple, scalar :returns: A list of items matching the coordinate-key description, or containing the scalar item. :rtype: list .. py:function:: get_dict(datablock, keys) Returns an element from a dictionary using a key or tuple of keys used to describe a path of keys :param datablock: The input dictionary :type datablock: dict :param keys: Dictionary key, or tuple of keys :type keys: str or tuple .. py:function:: set_dict(datablock, keys, object, create_missing=True) Sets an element in a dictionary using a key or tuple of keys used to describe a path of keys :param datablock: The input dictionary :type datablock: dict :param keys: Dictionary key, or tuple of keys :type keys: str or tuple :param object: The object to set in the dictionary :type object: any :param create_missing: If True, creates missing keys in the dictionary. Defaults to True. :type create_missing: bool, optional :raises KeyError: If a key in the path does not exist and create_missing is False.