ExactMatcher
Bases: Matcher
Exact matcher
Source code in pzp/matcher.py
45 46 47 48 49 50 51 52 |
|
ExtendedMatcher
Bases: Matcher
Extended Matcher
This matcher accept multiple patterns delimited by spaces, such as: term ^start end$ !not
If patter is prefixed by a single-quote character ', it will not be splitted by spaces.
A backslash can be prepend to a space to match a literal space character.
A term can be prefixed by ^, or suffixed by $ to become an anchored-match term. Then matcher will search for the lines that start with or end with the given string.
If a term is prefixed by !, the matcher will exclude the lines that satisfy the term from the result.
Source code in pzp/matcher.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
split_pattern(pattern)
Split a pattern into terms
Source code in pzp/matcher.py
148 149 150 151 152 153 |
|
ExtendedMatcherFilter
Source code in pzp/matcher.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
__call__(txt)
Evaluate the filter on the given text
Source code in pzp/matcher.py
89 90 91 92 93 94 |
|
always(txt)
Always return True
Source code in pzp/matcher.py
112 113 114 |
|
endswith_match(txt)
True if the text endswith the given term
Source code in pzp/matcher.py
100 101 102 |
|
exact_match(txt)
Exact match
Source code in pzp/matcher.py
108 109 110 |
|
in_match(txt)
True if the text contains the given term
Source code in pzp/matcher.py
104 105 106 |
|
split(term)
classmethod
Split term in prefix, term, suffix
Source code in pzp/matcher.py
82 83 84 85 86 87 |
|
startswith_match(txt)
True if the text startswith the given term
Source code in pzp/matcher.py
96 97 98 |
|
Matcher
Bases: ABC
Source code in pzp/matcher.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
__init_subclass__(option, **kwargs)
Register a subclass
Source code in pzp/matcher.py
24 25 26 27 |
|
filter(pattern, candidates, format_fn=lambda x: str(x))
abstractmethod
Filter candidates according to the given pattern
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern |
str
|
Pattern |
required |
candidates |
Sequence[Any]
|
Candidates |
required |
format_fn |
Callable[[Any], str]
|
Items format function |
lambda x: str(x)
|
Returns:
Name | Type | Description |
---|---|---|
result |
Sequence[Any]
|
Filtered candidates |
Source code in pzp/matcher.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
get_matcher(matcher)
Get a matcher instance by name or by class
Source code in pzp/matcher.py
156 157 158 159 160 161 162 163 |
|
list_matchers()
List matchers
Source code in pzp/matcher.py
166 167 168 |
|