MCPcopy
hub / github.com/mitmproxy/mitmproxy / parse

Function parse

mitmproxy/optmanager.py:526–545  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

524
525
526def parse(text):
527 if not text:
528 return {}
529 try:
530 yaml = ruamel.yaml.YAML(typ="safe", pure=True)
531 data = yaml.load(text)
532 except ruamel.yaml.error.YAMLError as v:
533 if hasattr(v, "problem_mark"):
534 snip = v.problem_mark.get_snippet()
535 raise exceptions.OptionsError(
536 "Config error at line %s:\n%s\n%s"
537 % (v.problem_mark.line + 1, snip, getattr(v, "problem", ""))
538 )
539 else:
540 raise exceptions.OptionsError("Could not parse options.")
541 if isinstance(data, str):
542 raise exceptions.OptionsError("Config error - no keys found.")
543 elif data is None:
544 return {}
545 return data
546
547
548def load(opts: OptManager, text: str, cwd: Path | str | None = None) -> None:

Callers 2

loadFunction · 0.70
serializeFunction · 0.70

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…