poco.sdk.DefaultMatcher module

class DefaultMatcher[源代码]

基类: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)[源代码]

See Also: IMatcher.match

class EqualizationComparator[源代码]

基类:object

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

class RegexpComparator[源代码]

基类: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)[源代码]
参数:
  • origin (str) – original string

  • pattern (str) – Regexp pattern string

返回:

True if matches otherwise False.

返回类型:

bool