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

Method __call__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

UsageErrorClass · 0.85
replaceMethod · 0.80
systemMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected