captest.util.update_by_path

captest.util.update_by_path(dictionary, path, new_value=None, convert_callable=False)

Update a nested dictionary value by following a path list.

Parameters:
  • dictionary (dict) – The dictionary to update

  • path (list) – A list representing the path to the target key

  • new_value (optional) – The new value to set (if None and convert_callable=True, will convert existing tuple to function name)

  • convert_callable (bool, optional) – If True and new_value is None, converts tuple to function name

Returns:

updated_dictionary – The updated dictionary

Return type:

dict