MCPcopy
hub / github.com/mitmproxy/mitmproxy / parsearg

Function parsearg

mitmproxy/command.py:304–314  ·  view source on GitHub ↗

Convert a string to a argument to the appropriate type.

(manager: CommandManager, spec: str, argtype: type)

Source from the content-addressed store, hash-verified

302
303
304def parsearg(manager: CommandManager, spec: str, argtype: type) -> Any:
305 """
306 Convert a string to a argument to the appropriate type.
307 """
308 t = mitmproxy.types.CommandTypes.get(argtype, None)
309 if not t:
310 raise exceptions.CommandError(f"Unsupported argument type: {argtype}")
311 try:
312 return t.parse(manager, argtype, spec)
313 except ValueError as e:
314 raise exceptions.CommandError(str(e)) from e
315
316
317def command(name: str | None = None):

Callers 1

prepare_argsMethod · 0.85

Calls 2

getMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…