Matches a flow against a compiled filter expression. Returns True if matched, False if not. If flt is a string, it will be compiled as a filter expression. If the expression is invalid, ValueError is raised.
(flt: str | TFilter, flow: flow.Flow)
| 669 | |
| 670 | |
| 671 | def match(flt: str | TFilter, flow: flow.Flow) -> bool: |
| 672 | """ |
| 673 | Matches a flow against a compiled filter expression. |
| 674 | Returns True if matched, False if not. |
| 675 | |
| 676 | If flt is a string, it will be compiled as a filter expression. |
| 677 | If the expression is invalid, ValueError is raised. |
| 678 | """ |
| 679 | if isinstance(flt, str): |
| 680 | flt = parse(flt) |
| 681 | if flt: |
| 682 | return flt(flow) |
| 683 | return True |
| 684 | |
| 685 | |
| 686 | match_all: TFilter = parse("~all") |