MCPcopy Create free account
hub / github.com/ipython/ipython / reverse_aliases

Function reverse_aliases

docs/autogen_config.py:83–101  ·  view source on GitHub ↗

Produce a mapping of trait names to lists of command line aliases.

(app)

Source from the content-addressed store, hash-verified

81 return '\n'.join(lines)
82
83def reverse_aliases(app):
84 """Produce a mapping of trait names to lists of command line aliases.
85 """
86 res = defaultdict(list)
87 for alias, trait in app.aliases.items():
88 res[trait].append(alias)
89
90 # Flags also often act as aliases for a boolean trait.
91 # Treat flags which set one trait to True as aliases.
92 for flag, (cfg, _) in app.flags.items():
93 if len(cfg) == 1:
94 classname = list(cfg)[0]
95 cls_cfg = cfg[classname]
96 if len(cls_cfg) == 1:
97 traitname = list(cls_cfg)[0]
98 if cls_cfg[traitname] is True:
99 res[classname+'.'+traitname].append(flag)
100
101 return res
102
103def write_doc(name, title, app, preamble=None):
104 trait_aliases = reverse_aliases(app)

Callers 1

write_docFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected