Execute a command by finding it in a list of patterns.
Parameters: |
|
---|
The list of patterns is a list of tuples, referenced here as “pattern”.
A “pattern” tuple has two items:
The command is also a tuple, with three elements:
If the patterns contains named references (e.g. (?P<xx>yyy)), these will be also placed in the named arguments dictionary.
Example:
patterns = [
(r'^x-(?P<tag>.*)$', (somefunc, (), {a=17})),
]
execute('x-abc', patterns)
Will call somefunc(a=17, tag='abc').