pology.match

Package pology :: Module match |

# Module match

Matchers and matcher helpers for various objects.

Author: Chusslove Illich (Часлав Илић) <caslav.ilic@gmx.net>

License: GPLv3

Classes
| ExprError Exception for errors in matching expressions.

Functions
make_filtered_msg(msg, cat, accels=None, filters=`[``]`) TODO: Write documentation. |
(msgf, msg, cat, hl=[])->bool |
make_msg_matcher(exprstr, mopts=None, abort=False) Build expression matcher for messages. |
(msg, cat, hl=[])->bool |
make_msg_fmatcher(exprstr, mopts=None, accels=None, filters=`[``]`, abort=False) Build expression matcher for messages, with filtering. |
make_matcher(name, value, mods, params, neg=False) TODO: Write documentation. |

Variables
| __package__ = ``'``pology``'``

Function Details

### make_msg_matcher(exprstr, mopts=None, abort=False) |
Build expression matcher for messages. For expression syntax, check `find-messages` sieve documentation for `fexpr` parameter. TODO: Put this instruction here. The `mopts` parameter, if given, defines global matching options. It can be either a dictionary or an object with data attributes, and can contain the following keys/attributes (in parenthesis: type and default value in case the key is not present): `case` (`bool`, `False`): `True` for case-sensitive matching The built matcher function takes up to four parameters, in order: `msgf`: filtered message (to really match against) `msg`: raw message (to properly report matched spans) `cat`: catalog in which the message resides `hl`: highlight specification (to be filled with matched spans, can be omitted from the call) Matcher function returns `True` if the message is matched, `False` otherwise. In case an error in expression is encountered while building the matcher, either ExprError exception may be thrown or execution aborted, depending on the parameter `abort`. Parameters: `exprstr` (string) - expression string `mopts` (dict or attribute object) - global matching options `abort` (bool) - on errors in expression, abort execution if `True`, raise ExprError if `False` Returns: (msgf, msg, cat, hl=[])->bool matcher function

### make_msg_fmatcher(exprstr, mopts=None, accels=None, filters=`[``]`, abort=False) |
Build expression matcher for messages, with filtering. Like make_msg_matcher, except that matchers built by this function do their own filtering, and so omit the first argument. For semantics of `accels` and `filters`, see this module documentation on `accel` and `filter` sieve parameters. Parameters: `exprstr` (string) - expression string `mopts` (attribute object) - global matching options `accels` (sequence of strings or `None`) - possible accelerator markers `filters` ((text)->text) - filters to apply to text fields [F1A hooks] `abort` (bool) - on errors, abort execution if `True`, raise exception if `False` Returns: (msg, cat, hl=[])->bool matcher function