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

Function parse_spec

mitmproxy/utils/spec.py:4–21  ·  view source on GitHub ↗

Parse strings in the following format: [/flow-filter]/subject/replacement

(option: str)

Source from the content-addressed store, hash-verified

2
3
4def parse_spec(option: str) -> tuple[flowfilter.TFilter, str, str]:
5 """
6 Parse strings in the following format:
7
8 [/flow-filter]/subject/replacement
9
10 """
11 sep, rem = option[0], option[1:]
12 parts = rem.split(sep, 2)
13 if len(parts) == 2:
14 subject, replacement = parts
15 return flowfilter.match_all, subject, replacement
16 elif len(parts) == 3:
17 patt, subject, replacement = parts
18 flow_filter = flowfilter.parse(patt)
19 return flow_filter, subject, replacement
20 else:
21 raise ValueError("Invalid number of parameters (2 or 3 are expected)")

Callers 5

test_parse_specFunction · 0.90
test_file_candidatesFunction · 0.90
parse_map_remote_specFunction · 0.90
parse_modify_specFunction · 0.90
parse_map_local_specFunction · 0.90

Calls 2

splitMethod · 0.45
parseMethod · 0.45

Tested by 2

test_parse_specFunction · 0.72
test_file_candidatesFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…