changeset 175:72de7d8566e2

tests finally passing
author catherine@dellzilla
date Fri, 12 Dec 2008 15:27:42 -0500
parents 471318e59e51
children 645467c0d3f9
files cmd2.py example/exampleSession.txt
diffstat 2 files changed, 21 insertions(+), 3 deletions(-) [+]
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()        
--- 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