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

Class MagicArgumentParser

IPython/core/magic_arguments.py:105–136  ·  view source on GitHub ↗

An ArgumentParser tweaked for use by IPython magics.

Source from the content-addressed store, hash-verified

103 super(MagicHelpFormatter, self).add_usage(usage, actions, groups, prefix)
104
105class MagicArgumentParser(argparse.ArgumentParser):
106 """ An ArgumentParser tweaked for use by IPython magics.
107 """
108 def __init__(self,
109 prog=None,
110 usage=None,
111 description=None,
112 epilog=None,
113 parents=None,
114 formatter_class=MagicHelpFormatter,
115 prefix_chars='-',
116 argument_default=None,
117 conflict_handler='error',
118 add_help=False):
119 if parents is None:
120 parents = []
121 super(MagicArgumentParser, self).__init__(prog=prog, usage=usage,
122 description=description, epilog=epilog,
123 parents=parents, formatter_class=formatter_class,
124 prefix_chars=prefix_chars, argument_default=argument_default,
125 conflict_handler=conflict_handler, add_help=add_help)
126
127 def error(self, message):
128 """ Raise a catchable error instead of exiting.
129 """
130 raise UsageError(message)
131
132 def parse_argstring(self, argstring):
133 """ Split a string into an argument list and parse that argument list.
134 """
135 argv = arg_split(argstring)
136 return self.parse_args(argv)
137
138
139def construct_parser(magic_func):

Callers 1

construct_parserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected