MCPcopy Index your code
hub / github.com/ipython/ipython / reverse_aliases

Function reverse_aliases

docs/autogen_config.py:81–99  ·  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

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

Callers 1

write_docFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…