# HG changeset patch # User catherine@dellzilla # Date 1229113662 18000 # Node ID 72de7d8566e2ebbd854ed4cc3924abce0a923d7e # Parent 471318e59e5143a073295a66843aedc4b9c77908 tests finally passing diff -r 471318e59e51 -r 72de7d8566e2 cmd2.py --- 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() diff -r 471318e59e51 -r 72de7d8566e2 example/exampleSession.txt --- a/example/exampleSession.txt Fri Dec 12 15:12:37 2008 -0500 +++ b/example/exampleSession.txt Fri Dec 12 15:27:42 2008 -0500 @@ -1,6 +1,3 @@ -(Cmd) & look, a shortcut! -look, a shortcut! -(Cmd) say put this in a file > myfile.txt (Cmd) say < myfile.txt put this in a file (Cmd) # comments do nothing