comparison cmd2.py @ 295:f5593299fc2a

debugged snarl in saving .parser
author catherine@bothari
date Sun, 24 Jan 2010 06:59:36 -0500
parents e7c89e34b39b
children ae476b714190
comparison
equal deleted inserted replaced
294:e7c89e34b39b 295:f5593299fc2a
126 print e 126 print e
127 optionParser.print_help() 127 optionParser.print_help()
128 return 128 return
129 if hasattr(opts, '_exit'): 129 if hasattr(opts, '_exit'):
130 return None 130 return None
131 if hasattr(arg, 'parser'): 131 if hasattr(arg, 'parsed'):
132 terminator = arg.parsed.terminator 132 terminator = arg.parsed.terminator
133 try: 133 try:
134 if arg.parsed.terminator[0] == '\n': 134 if arg.parsed.terminator[0] == '\n':
135 terminator = arg.parsed.terminator[0] 135 terminator = arg.parsed.terminator[0]
136 except IndexError: 136 except IndexError:
321 abbrev = True # Abbreviated commands recognized 321 abbrev = True # Abbreviated commands recognized
322 current_script_dir = None 322 current_script_dir = None
323 reserved_words = [] 323 reserved_words = []
324 feedback_to_output = False # Do include nonessentials in >, | output 324 feedback_to_output = False # Do include nonessentials in >, | output
325 quiet = False # Do not suppress nonessential output 325 quiet = False # Do not suppress nonessential output
326 debug = False 326 debug = True
327 settable = ''' 327 settable = '''
328 prompt 328 prompt
329 continuation_prompt 329 continuation_prompt
330 debug 330 debug
331 default_file_name for `save`, `load`, etc. 331 default_file_name for `save`, `load`, etc.
640 result['raw'] = raw 640 result['raw'] = raw
641 result['clean'] = self.commentGrammars.transformString(result.args) # oh no, strips ls box/* 641 result['clean'] = self.commentGrammars.transformString(result.args) # oh no, strips ls box/*
642 result['expanded'] = s 642 result['expanded'] = s
643 p = ParsedString(result.clean) 643 p = ParsedString(result.clean)
644 p.parsed = result 644 p.parsed = result
645 p.parser = self.parsed
645 for (key, val) in kwargs.items(): 646 for (key, val) in kwargs.items():
646 p.parsed[key] = val 647 p.parsed[key] = val
647 return p 648 return p
648 649
649 def postparsing_precmd(self, statement): 650 def postparsing_precmd(self, statement):
728 # "heart" of the command, replaces cmd's onecmd() 729 # "heart" of the command, replaces cmd's onecmd()
729 self.lastcmd = statement.parsed.expanded 730 self.lastcmd = statement.parsed.expanded
730 funcname = self.func_named(statement.parsed.command) 731 funcname = self.func_named(statement.parsed.command)
731 full_statement = ParsedString(statement.parsed.raw) 732 full_statement = ParsedString(statement.parsed.raw)
732 full_statement.parsed = statement.parsed 733 full_statement.parsed = statement.parsed
734 full_statement.parser = statement.parser
733 if not funcname: 735 if not funcname:
734 return self.postparsing_postcmd(self.default(full_statement)) 736 return self.postparsing_postcmd(self.default(full_statement))
735 try: 737 try:
736 func = getattr(self, funcname) 738 func = getattr(self, funcname)
737 except AttributeError: 739 except AttributeError: