Mercurial > python-cmd2
comparison cmd2.py @ 163:61a57c44cd93
ugh - parsing stripping command causes real trouble
author | catherine@dellzilla |
---|---|
date | Wed, 03 Dec 2008 17:21:08 -0500 |
parents | c50615cf814f |
children | 5209d230f96b |
comparison
equal
deleted
inserted
replaced
162:c50615cf814f | 163:61a57c44cd93 |
---|---|
415 for (shortcut, expansion) in self.shortcuts.items(): | 415 for (shortcut, expansion) in self.shortcuts.items(): |
416 if s.startswith(shortcut): | 416 if s.startswith(shortcut): |
417 s = s.replace(shortcut, expansion + ' ', 1) | 417 s = s.replace(shortcut, expansion + ' ', 1) |
418 break | 418 break |
419 result = self.parser.parseString(s) | 419 result = self.parser.parseString(s) |
420 if useTerminatorFrom: | |
421 return self.parsed('%s %s%s%s' % (result.command, result.args, useTerminatorFrom.parsed.terminator, useTerminatorFrom.parsed.suffix)) | |
420 result['command'] = result.multilineCommand or result.command | 422 result['command'] = result.multilineCommand or result.command |
421 result['raw'] = raw | 423 result['raw'] = raw |
422 result['clean'] = self.commentGrammars.transformString(result.args) | 424 result['clean'] = self.commentGrammars.transformString(result.args) |
423 result['expanded'] = s | 425 result['expanded'] = s |
424 if useTerminatorFrom: | |
425 result['terminator'] = useTerminatorFrom.parsed.terminator | |
426 result['suffix'] = useTerminatorFrom.parsed.suffix | |
427 p = ParsedString(result.args) | 426 p = ParsedString(result.args) |
428 p.parsed = result | 427 p.parsed = result |
429 p.parser = self.parsed | 428 p.parser = self.parsed |
430 return p | 429 return p |
431 | 430 |
606 raise NotSettableError | 605 raise NotSettableError |
607 currentVal = getattr(self, paramName) | 606 currentVal = getattr(self, paramName) |
608 if (val[0] == val[-1]) and val[0] in ("'", '"'): | 607 if (val[0] == val[-1]) and val[0] in ("'", '"'): |
609 val = val[1:-1] | 608 val = val[1:-1] |
610 else: | 609 else: |
611 val = cast(currentVal, self.parsed(val).statement) | 610 val = cast(currentVal, val) |
612 setattr(self, paramName, val) | 611 setattr(self, paramName, val) |
613 self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val)) | 612 self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val)) |
614 except (ValueError, AttributeError, NotSettableError), e: | 613 except (ValueError, AttributeError, NotSettableError), e: |
615 self.do_show(arg) | 614 self.do_show(arg) |
616 | 615 |