comparison cmd2.py @ 175:72de7d8566e2

tests finally passing
author catherine@dellzilla
date Fri, 12 Dec 2008 15:27:42 -0500
parents 471318e59e51
children 645467c0d3f9
comparison
equal deleted inserted replaced
174:471318e59e51 175:72de7d8566e2
456 self.pseudo_raw_input(self.continuationPrompt))) 456 self.pseudo_raw_input(self.continuationPrompt)))
457 except Exception, e: 457 except Exception, e:
458 print e 458 print e
459 return 0 459 return 0
460 460
461 if not statement:
462 return 0
463
461 statekeeper = None 464 statekeeper = None
462 stop = 0 465 stop = 0
463 466
464 if statement.parsed.pipeTo: 467 if statement.parsed.pipeTo:
465 redirect = subprocess.Popen(statement.parsed.pipeTo, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) 468 redirect = subprocess.Popen(statement.parsed.pipeTo, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
914 elif line.startswith(continuationPrompt): 917 elif line.startswith(continuationPrompt):
915 command.append(line[len(continuationPrompt)+1:]) 918 command.append(line[len(continuationPrompt)+1:])
916 else: 919 else:
917 if responseStart < commandStart: 920 if responseStart < commandStart:
918 responseStart = lineNum 921 responseStart = lineNum
922 def divideTranscript(self):
923 self.dialogue = []
924 commandStart = None
925 response = []
926 command = []
927 prompt = self.cmdapp.prompt.rstrip()
928 continuationPrompt = self.cmdapp.continuationPrompt.rstrip()
929 for (lineNum, line) in enumerate(self.transcript):
930 if line.startswith(prompt):
931 if command:
932 self.dialogue.append((commandStart, ''.join(command), ''.join(response)))
933 command = [line[len(prompt)+1:]]
934 commandStart = lineNum
935 response = []
936 elif line.startswith(continuationPrompt):
937 command.append(line[len(continuationPrompt)+1:])
938 else:
939 response.append(line)
919 def testall(self): 940 def testall(self):
920 if self.CmdApp: 941 if self.CmdApp:
921 self.divideTranscript() 942 self.divideTranscript()
922 for (lineNum, command, expected) in self.dialogue: 943 for (lineNum, command, expected) in self.dialogue:
923 self.cmdapp.onecmd(command) 944 self.cmdapp.onecmd(command)