Dumps the options into a list of dict object. Return: A list like: { "anticache": { type: "bool", default: false, value: true, help: "help text"} }
(opts, keys: Iterable[str] | None = None)
| 501 | |
| 502 | |
| 503 | def dump_dicts(opts, keys: Iterable[str] | None = None) -> dict: |
| 504 | """ |
| 505 | Dumps the options into a list of dict object. |
| 506 | |
| 507 | Return: A list like: { "anticache": { type: "bool", default: false, value: true, help: "help text"} } |
| 508 | """ |
| 509 | options_dict = {} |
| 510 | if keys is None: |
| 511 | keys = opts.keys() |
| 512 | for k in sorted(keys): |
| 513 | o = opts._options[k] |
| 514 | t = typecheck.typespec_to_str(o.typespec) |
| 515 | option = { |
| 516 | "type": t, |
| 517 | "default": o.default, |
| 518 | "value": o.current(), |
| 519 | "help": o.help, |
| 520 | "choices": o.choices, |
| 521 | } |
| 522 | options_dict[k] = option |
| 523 | return options_dict |
| 524 | |
| 525 | |
| 526 | def parse(text): |