MCPcopy Create free account
hub / github.com/ipython/traitlets / emit_flag_help

Method emit_flag_help

traitlets/config/application.py:556–578  ·  view source on GitHub ↗

Yield the lines for the flag part of the help.

(self)

Source from the content-addressed store, hash-verified

554 print("\n".join(self.emit_flag_help()))
555
556 def emit_flag_help(self) -> t.Generator[str, None, None]:
557 """Yield the lines for the flag part of the help."""
558 if not self.flags:
559 return
560
561 for flags, (cfg, fhelp) in self.flags.items():
562 try:
563 if not isinstance(flags, tuple): # type:ignore[unreachable]
564 flags = (flags,) # type:ignore[assignment]
565 flags = sorted(flags, key=len) # type:ignore[assignment]
566 flags = ", ".join(("--%s" if len(m) > 1 else "-%s") % m for m in flags)
567 yield flags
568 yield indent(dedent(fhelp.strip()))
569 cfg_list = " ".join(
570 f"--{clname}.{prop}={val}"
571 for clname, props_dict in cfg.items()
572 for prop, val in props_dict.items()
573 )
574 cfg_txt = "Equivalent to: [%s]" % cfg_list
575 yield indent(dedent(cfg_txt))
576 except Exception as ex:
577 self.log.error("Failed collecting help-message for flag %r, due to: %s", flags, ex)
578 raise
579
580 def print_options(self) -> None:
581 """Print the options part of the help."""

Callers 2

print_flag_helpMethod · 0.95
emit_options_helpMethod · 0.95

Calls 2

indentFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected