flowbber.utils.filter

Utilities for filtering data.

Functions

  • included_in(): Check if the given value is included in the given list of patterns.
  • is_wanted(): Check that the given value is included in the include list and not included
  • filter_dict(): Filter a dictionary using the provided include and exclude patterns.
flowbber.utils.filter.included_in(value, patterns)

Check if the given value is included in the given list of patterns.

Parameters
  • value (str) – The value to check for.
  • patterns (list) – List of patterns to check for.
Returns

True in the value is included, False otherwise.

Return type

bool

flowbber.utils.filter.is_wanted(value, include, exclude)

Check that the given value is included in the include list and not included in the exclude list.

Parameters
  • value (str) – The value to check for.
  • include (list) – List of patterns of values to include.
  • exclude (list) – List of patterns of values to exclude.
Returns

True in the value is wanted, False otherwise.

Return type

bool

flowbber.utils.filter.filter_dict(data, include, exclude, joinchar='.')

Filter a dictionary using the provided include and exclude patterns.

Parameters
  • data (dict) – The data to filter (dict or OrderedDict, type is respected).
  • include (list) – List of patterns of key paths to include.
  • exclude (list) – List of patterns of key paths to exclude.
  • joinchar (str) – String used to join the keys to form the path.
Returns

The filtered dictionary.

Return type

dict or OrderedDict