tethys.core.pipes.filters.filter_json_content

Module Contents

class tethys.core.pipes.filters.filter_json_content.SimpleJsonPathFilter(path_expression: str, value_filter_func: Callable, pass_no_json: bool = False, calc_score: bool = False)[source]

Bases: tethys.core.pipes.filters.filter_base.FilterBase

This filter executes user’s function for each matched value (with the JSONPath expression) and calculate a score.

Parameters
  • path_expression (str) – json-path expression

  • value_filter_func (Callable) – Function which return True/False depends on the value

  • pass_no_json (bool) – if data_packet is not json (or python object) then the filter return the score like 1.0 else 0.0

  • calc_score (bool) – if True then the filter return (success_filtered_matches / all_matches) else return 1 or 0

execute(self, data_packet: Any, **kwargs)[source]

Execute value_filter_func() for each matched value and calculate the score as a percent of the success executes.

Parameters

data_packet – any data object

Returns

calculated score (float)