bexchange.matching package

Submodules

bexchange.matching.filters module

class bexchange.matching.filters.always_filter[source]

Bases: node_filter

always filter for returning true

classmethod from_value(value, manager)[source]
Used to create a not filter from a dictionary containing the information about this not filter. Format is:

{“filter_type”: “always_filter”}

Parameters:
  • value – The dictionary

  • manager – The manager used to instantiate objects

classmethod name_repr()[source]

Returns the name of this filter :return: name of this filter

to_xpr()[source]

Creates an expression to be used when matching against metadata. :return: The expression

class bexchange.matching.filters.and_filter(childs)[source]

Bases: node_filter

and filter for combining several different expressions

classmethod from_value(value, manager)[source]
Used to create an and filter from a dictionary containing the information about this and filter. Format is:
{“filter_type”: “and_filter”,

“value”: []}

Parameters:
  • value – The dictionary

  • manager – The manager used to instantiate objects

classmethod name_repr()[source]

Returns the name of this filter :return: name of this filter

to_xpr()[source]

Creates an expression to be used when matching against metadata. :return: The expression

class bexchange.matching.filters.attribute_filter(name, op, t, v)[source]

Bases: node_filter

an attribute filter that is used to match a specific attribute against a value.

classmethod from_value(v, manager)[source]
Used to create an attribute filter from a dictionary containing the information about this attribute filter. Format is:
{“filter_type”: “attribute_filter”,

“name”: “_bdb/source_name”, “operation”: “in”, “value_type”: “string”, “value”: [“sehem”,”seang”]}

Parameters:
  • v – The dictionary

  • manager – The manager used to instantiate objects

classmethod name_repr()[source]

Name of this class

to_xpr()[source]

Creates an expression to be used when matching against metadata. :return: The expression

class bexchange.matching.filters.filter_manager[source]

Bases: object

The filter manager is used to create a filter from a dictionary or json entry

from_json(s)[source]

Creates a object from a json entry if it can be parsed :param value: The json entry. If json entry (dictionary) contains “filter_type” and “value”, an atempt will be made to create the filter” :return: A filter object on success :raise KeyError: If filter_type has not been registered

from_value(value)[source]

Creates a object from a dictionary if it can be parsed :param value: The dictionary. If dictionary contains “filter_type” and “value”, an atempt will be made to create the filter” :return: A filter object on success :raise KeyError: If filter_type has not been registered

to_json(ifilter)[source]

Creates a json entry from a filter :param ifilter: The filter to be jsonifyed… :return: a filter as a json string

to_xpr(ifilter)[source]

Creates an expression to be used when matching against metadata. :return: The expression

class bexchange.matching.filters.node_filter[source]

Bases: object

to_xpr()[source]

Translates a filter object to a list of expression symbols :return: a list of symbols

class bexchange.matching.filters.not_filter(child)[source]

Bases: node_filter

not filter for negating an expression

classmethod from_value(value, manager)[source]
Used to create a not filter from a dictionary containing the information about this not filter. Format is:
{“filter_type”: “not_filter”,

“value”: …}

Parameters:
  • value – The dictionary

  • manager – The manager used to instantiate objects

classmethod name_repr()[source]

Returns the name of this filter :return: name of this filter

to_xpr()[source]

Creates an expression to be used when matching against metadata. :return: The expression

class bexchange.matching.filters.or_filter(childs)[source]

Bases: node_filter

or filter for combining several different expressions

classmethod from_value(value, manager)[source]
Used to create an or filter from a dictionary containing the information about this or filter. Format is:
{“filter_type”: “or_filter”,

“value”: [….]}

Parameters:
  • value – The dictionary

  • manager – The manager used to instantiate objects

classmethod name_repr()[source]

Returns the name of this filter :return: name of this filter

to_xpr()[source]

Creates an expression to be used when matching against metadata. :return: The expression

bexchange.matching.metadata_matcher module

class bexchange.matching.metadata_matcher.metadata_matcher[source]

Bases: object

Used for matching metadata against an expression

find_plain(name, ttype)[source]

Finds any name within the metadata. :param name: The name of the attribute :param ttype: Not used :return: The value

find_source(name, source)[source]

Finds a source identifier within the source. :param name: The source identifier :param source: The data source :return the found value

find_value(name, ttype)[source]

Finds a value within the metadata with specified name :param name: The name that is requested :param ttype: The type we are looking for :return: the value if found

in_(lhs, rhs)[source]

Matches if items in lhs exists in the rhs. :param lhs: Left hand side which is a list of values :param rhs: Right hand side which is matched against :return: True or False

init_evaluator()[source]

Sets up all operations available for the filter

like(lhs, rhs)[source]

Matches against a *-pattern. :param lhs: Left hand side which is a list of value :param rhs: Right hand side which is pattern :return: True or False

match(metadata, xpr)[source]

Matches the metadata against the expression. Synchronized. :param metadata: The metadata to be matched against :param xpr: The expression matched against :return: True or False

match_path(split_path, nodepath)[source]

Matches the paths

Module contents