Dumps an annotated file with all options.
(opts, out: TextIO)
| 479 | |
| 480 | |
| 481 | def 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 | |
| 503 | def dump_dicts(opts, keys: Iterable[str] | None = None) -> dict: |