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

Function dump_defaults

mitmproxy/optmanager.py:481–500  ·  view source on GitHub ↗

Dumps an annotated file with all options.

(opts, out: TextIO)

Source from the content-addressed store, hash-verified

479
480
481def dump_defaults(opts, out: TextIO):
482 """
483 Dumps an annotated file with all options.
484 """
485 # Sort data
486 s = ruamel.yaml.comments.CommentedMap()
487 for k in sorted(opts.keys()):
488 o = opts._options[k]
489 s[k] = o.default
490 txt = o.help.strip()
491
492 if o.choices:
493 txt += " Valid values are %s." % ", ".join(repr(c) for c in o.choices)
494 else:
495 t = typecheck.typespec_to_str(o.typespec)
496 txt += " Type %s." % t
497
498 txt = "\n".join(textwrap.wrap(txt))
499 s.yaml_set_comment_before_after_key(k, before="\n" + txt)
500 return ruamel.yaml.YAML().dump(s, out)
501
502
503def dump_dicts(opts, keys: Iterable[str] | None = None) -> dict:

Callers

nothing calls this directly

Calls 3

keysMethod · 0.45
joinMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…