(self, rest='')
| 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 |
nothing calls this directly
no test coverage detected