poco.sdk.DefaultMatcher module

class DefaultMatcher[source]

Bases: IMatcher

Default matcher implementation for poco hierarchy traversing. Including logical query condition and predicate expression. When traversing through the hierarchy tree, matcher will apply the match method on each node of the tree.

The formal definition of query condition as follows:

expr := (op0, (expr0, expr1, ...))
expr := (op1, (arg1, arg2))
  • op0str is logical operator (‘or’ or ‘and’) which has the same semantics as in python, e.g. ‘or’ means this expression/condition matches if any of the exprN matches

  • op1str is comparator, can be one of as follows:

    op1 := 'attr='
    op1 := 'attr.*='
    op1 := ... (other customized)

    The op1 must be a string. The Matcher will help to map to Comparator object.

match(cond, node)[source]

See Also: IMatcher.match

class EqualizationComparator[source]

Bases: object

Compare two objects using the native equivalence (==) comparison operator

class RegexpComparator[source]

Bases: object

Compare two objects using regular expression. Available only when the original value is string type. It always returns False if the original value or given pattern are not str type.

compare(origin, pattern)[source]
  • origin (str) – original string

  • pattern (str) – Regexp pattern string


True if matches otherwise False.

Return type: