polyswarmclient.filters.filter

Module Contents

polyswarmclient.filters.filter.logger[source]
polyswarmclient.filters.filter.parse_filters(ctx, param, value)[source]
Split some filters into a dict separated by type
Parameters
  • ctx

  • param

  • value – list of 4 string tuples

Returns

Dict where each key points to a list of Filters

Return type

dict

class polyswarmclient.filters.filter.FilterComparison[source]

Bases: enum.Enum

Enum of supported metadata comparisons

LT = <[source]
LTE = <=[source]
EQ = ==[source]
GTE = >=[source]
GT = >[source]
CONTAINS = contains[source]
STARTS_WITH = startswith[source]
ENDS_WITH = endswith[source]
REGEX = regex[source]
__repr__(self)[source]
static from_string(value)[source]
class polyswarmclient.filters.filter.Filter(key, comparison, target_value)[source]

Filter some metadata value

__eq__(self, other)[source]
__repr__(self)[source]
number_check(self, value)[source]

Check a value as a number with GT, GTE, LT, or LTE comparisons

Parameters

value (str|int|float|bytes) – Value to compare against

Returns: (bool) returns True if comparison matches

string_check(self, value)[source]

Check a value as a string with EQ, CONTAINS, STARTS_WITH, ENDS_WITH, and REGEX comparisons

Parameters

value (str|int|float|bytes) – Value to compare against

Returns: (bool) returns True if comparison matches

filter(self, metadata)[source]

Take some metadata, and matches the given key against the target_value and comparison operator for this filter

Parameters

metadata (dict) – Dict of k-v metadata values

Returns: (bool) True if it matches the filter

class polyswarmclient.filters.filter.MetadataFilter[source]

Takes two objects list[Filter], accept and reject These dicts are used to filter metadata json blobs. Each filter runs against given metadata, and is used to determine if this participant will respond to a bounty

static pad_metadata(metadata, min_length)[source]

Pad out the metadata list with None values to match a given length

Parameters
  • metadata (list[dict|None]) – List of metadata dicts

  • min_length (int) – Min size for the metadata list after padding

Returns

list of metadata dicts, or None values