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

Function construct_parser

IPython/core/magic_arguments.py:139–158  ·  view source on GitHub ↗

Construct an argument parser using the function decorations.

(magic_func)

Source from the content-addressed store, hash-verified

137
138
139def construct_parser(magic_func):
140 """ Construct an argument parser using the function decorations.
141 """
142 kwds = getattr(magic_func, 'argcmd_kwds', {})
143 if 'description' not in kwds:
144 kwds['description'] = getattr(magic_func, '__doc__', None)
145 arg_name = real_name(magic_func)
146 parser = MagicArgumentParser(arg_name, **kwds)
147 # Reverse the list of decorators in order to apply them in the
148 # order in which they appear in the source.
149 group = None
150 for deco in magic_func.decorators[::-1]:
151 result = deco.add_to_parser(parser, group)
152 if result is not None:
153 group = result
154
155 # Replace the magic function's docstring with the full help text.
156 magic_func.__doc__ = parser.format_help()
157
158 return parser
159
160
161def parse_argstring(magic_func, argstring):

Callers 1

__call__Method · 0.85

Calls 3

real_nameFunction · 0.85
MagicArgumentParserClass · 0.85
add_to_parserMethod · 0.45

Tested by

no test coverage detected