changeset 174:76737c0535b8

starting to pyparse transcript properly
author catherine@dellzilla
date Thu, 23 Oct 2008 16:20:45 -0400
parents f5a1d7e7bd59
children f19e4c198251
files sqlpython/test_sqlpyPlus.py
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/test_sqlpyPlus.py	Thu Oct 23 15:14:46 2008 -0400
+++ b/sqlpython/test_sqlpyPlus.py	Thu Oct 23 16:20:45 2008 -0400
@@ -57,4 +57,21 @@
 except IndexError:
     print 'Usage: python %s username/password@oracleSID' % os.path.split(__file__)[-1]
     sys.exit()
-unittest.main()
\ No newline at end of file
+unittest.main()
+
+
+
+transcript = open('test_sqlpyPlus.txt')
+transcript = transcript.read()
+from pyparsing import *
+prompt = lineStart +'testdata@eqdev> '
+continuationPrompt = lineStart + '> '
+command = (Suppress(prompt) + restOfLine + ZeroOrMore(lineEnd + Suppress(continuationPrompt) + restOfLine))("command")
+results = command.scanString(transcript)
+cmds = []
+laststart = 0
+for result in results:
+    if len(cmds) > 0:
+        cmds[-1][1] = transcript[laststart:result[1]]
+    cmds.append([''.join(result[0].command), transcript[result[2]:]])
+    laststart = result[2]