MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / parse

Function parse

mitmproxy/flowfilter.py:656–668  ·  view source on GitHub ↗

Parse a filter expression and return the compiled filter function. If the filter syntax is invalid, `ValueError` is raised.

(s: str)

Source from the content-addressed store, hash-verified

654
655
656def parse(s: str) -> TFilter:
657 """
658 Parse a filter expression and return the compiled filter function.
659 If the filter syntax is invalid, `ValueError` is raised.
660 """
661 if not s:
662 raise ValueError("Empty filter expression")
663 try:
664 flt = bnf.parseString(s, parseAll=True)[0]
665 flt.pattern = s
666 return flt
667 except (pp.ParseException, ValueError) as e:
668 raise ValueError(f"Invalid filter expression: {s!r}") from e
669
670
671def match(flt: str | TFilter, flow: flow.Flow) -> bool:

Callers 2

matchFunction · 0.70
flowfilter.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…