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

Class MagicArgumentParser

IPython/core/magic_arguments.py:137–170  ·  view source on GitHub ↗

An ArgumentParser tweaked for use by IPython magics.

Source from the content-addressed store, hash-verified

135 super(MagicHelpFormatter, self).add_usage(usage, actions, groups, prefix)
136
137class MagicArgumentParser(argparse.ArgumentParser):
138 """ An ArgumentParser tweaked for use by IPython magics.
139 """
140 def __init__(self,
141 prog=None,
142 usage=None,
143 description=None,
144 epilog=None,
145 parents=None,
146 formatter_class=MagicHelpFormatter,
147 prefix_chars='-',
148 argument_default=None,
149 conflict_handler='error',
150 add_help=False):
151 if parents is None:
152 parents = []
153 super(MagicArgumentParser, self).__init__(prog=prog, usage=usage,
154 description=description, epilog=epilog,
155 parents=parents, formatter_class=formatter_class,
156 prefix_chars=prefix_chars, argument_default=argument_default,
157 conflict_handler=conflict_handler, add_help=add_help)
158
159 def error(self, message):
160 """ Raise a catchable error instead of exiting.
161 """
162 raise UsageError(message)
163
164 def parse_argstring(self, argstring, *, partial=False):
165 """ Split a string into an argument list and parse that argument list.
166 """
167 argv = arg_split(argstring, strict=not partial)
168 if partial:
169 return self.parse_known_args(argv)
170 return self.parse_args(argv)
171
172
173def construct_parser(magic_func):

Callers 1

construct_parserFunction · 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…