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

Function construct_parser

IPython/core/magic_arguments.py:173–192  ·  view source on GitHub ↗

Construct an argument parser using the function decorations.

(magic_func)

Source from the content-addressed store, hash-verified

171
172
173def construct_parser(magic_func):
174 """ Construct an argument parser using the function decorations.
175 """
176 kwds = getattr(magic_func, 'argcmd_kwds', {})
177 if 'description' not in kwds:
178 kwds['description'] = getattr(magic_func, '__doc__', None)
179 arg_name = real_name(magic_func)
180 parser = MagicArgumentParser(arg_name, **kwds)
181 # Reverse the list of decorators in order to apply them in the
182 # order in which they appear in the source.
183 group = None
184 for deco in magic_func.decorators[::-1]:
185 result = deco.add_to_parser(parser, group)
186 if result is not None:
187 group = result
188
189 # Replace the magic function's docstring with the full help text.
190 magic_func.__doc__ = parser.format_help()
191
192 return parser
193
194
195def parse_argstring(magic_func, argstring, *, partial=False):

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…