Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
spec.py22 linesDownload Raw Back to utils
1from mitmproxy import flowfilter2 3 4def parse_spec(option: str) -> tuple[flowfilter.TFilter, str, str]:5    """6    Parse strings in the following format:7 8        [/flow-filter]/subject/replacement9 10    """11    sep, rem = option[0], option[1:]12    parts = rem.split(sep, 2)13    if len(parts) == 2:14        subject, replacement = parts15        return flowfilter.match_all, subject, replacement16    elif len(parts) == 3:17        patt, subject, replacement = parts18        flow_filter = flowfilter.parse(patt)19        return flow_filter, subject, replacement20    else:21        raise ValueError("Invalid number of parameters (2 or 3 are expected)")22 
codekingpro/portable-devtools · Team Ai