Mercurial > python-cmd2
diff cmd2.py @ 175:72de7d8566e2
tests finally passing
author | catherine@dellzilla |
---|---|
date | Fri, 12 Dec 2008 15:27:42 -0500 |
parents | 471318e59e51 |
children | 645467c0d3f9 |
line wrap: on
line diff
--- a/cmd2.py Fri Dec 12 15:12:37 2008 -0500 +++ b/cmd2.py Fri Dec 12 15:27:42 2008 -0500 @@ -458,6 +458,9 @@ print e return 0 + if not statement: + return 0 + statekeeper = None stop = 0 @@ -916,6 +919,24 @@ else: if responseStart < commandStart: responseStart = lineNum + def divideTranscript(self): + self.dialogue = [] + commandStart = None + response = [] + command = [] + prompt = self.cmdapp.prompt.rstrip() + continuationPrompt = self.cmdapp.continuationPrompt.rstrip() + for (lineNum, line) in enumerate(self.transcript): + if line.startswith(prompt): + if command: + self.dialogue.append((commandStart, ''.join(command), ''.join(response))) + command = [line[len(prompt)+1:]] + commandStart = lineNum + response = [] + elif line.startswith(continuationPrompt): + command.append(line[len(continuationPrompt)+1:]) + else: + response.append(line) def testall(self): if self.CmdApp: self.divideTranscript()