Mercurial > python-cmd2
comparison cmd2.py @ 299:7d256086fa1b
trying to simplify parse results
author | catherine@dellzilla |
---|---|
date | Tue, 26 Jan 2010 17:23:44 -0500 |
parents | a94e3b39d787 |
children | 1e4773b325d1 |
comparison
equal
deleted
inserted
replaced
298:a94e3b39d787 | 299:7d256086fa1b |
---|---|
129 optionParser.print_help() | 129 optionParser.print_help() |
130 return | 130 return |
131 if hasattr(opts, '_exit'): | 131 if hasattr(opts, '_exit'): |
132 return None | 132 return None |
133 if hasattr(arg, 'parsed'): | 133 if hasattr(arg, 'parsed'): |
134 arg.parsed.args = newArgs | |
134 terminator = arg.parsed.terminator | 135 terminator = arg.parsed.terminator |
135 try: | 136 try: |
136 if arg.parsed.terminator[0] == '\n': | 137 if arg.parsed.terminator[0] == '\n': |
137 terminator = arg.parsed.terminator[0] | 138 terminator = arg.parsed.terminator[0] |
138 except IndexError: | 139 except IndexError: |
638 s = s.replace(shortcut, expansion + ' ', 1) | 639 s = s.replace(shortcut, expansion + ' ', 1) |
639 break | 640 break |
640 result = self.parser.parseString(s) | 641 result = self.parser.parseString(s) |
641 result['command'] = result.multilineCommand or result.command | 642 result['command'] = result.multilineCommand or result.command |
642 result['raw'] = raw | 643 result['raw'] = raw |
643 result['clean'] = self.commentGrammars.transformString(result.args) # oh no, strips ls box/* | 644 result['comments_removed'] = self.commentGrammars.transformString(result.args) |
644 result['expanded'] = s | 645 result['expanded'] = s |
645 p = ParsedString(result.clean) | 646 p = ParsedString(result.comments_removed) |
646 p.parsed = result | 647 p.parsed = result |
647 p.parser = self.parsed | 648 p.parser = self.parsed |
648 for (key, val) in kwargs.items(): | 649 for (key, val) in kwargs.items(): |
649 p.parsed[key] = val | 650 p.parsed[key] = val |
650 return p | 651 return p |