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

Method __call__

IPython/core/alias.py:165–186  ·  view source on GitHub ↗
(self, rest='')

Source from the content-addressed store, hash-verified

163 return "<alias {} for {!r}>".format(self.name, self.cmd)
164
165 def __call__(self, rest=''):
166 cmd = self.cmd
167 nargs = self.nargs
168 # Expand the %l special to be the user's input line
169 if cmd.find('%l') >= 0:
170 cmd = cmd.replace('%l', rest)
171 rest = ''
172
173 if nargs==0:
174 if cmd.find('%%s') >= 1:
175 cmd = cmd.replace('%%s', '%s')
176 # Simple, argument-less aliases
177 cmd = '%s %s' % (cmd, rest)
178 else:
179 # Handle aliases with positional arguments
180 args = rest.split(None, nargs)
181 if len(args) < nargs:
182 raise UsageError('Alias <%s> requires %s arguments, %s given.' %
183 (self.name, nargs, len(args)))
184 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
185
186 self.shell.system(cmd)
187
188#-----------------------------------------------------------------------------
189# Main AliasManager class

Callers

nothing calls this directly

Calls 3

UsageErrorClass · 0.85
systemMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected