changeset 175:f19e4c198251

before adding testing
author catherine@dellzilla
date Tue, 28 Oct 2008 15:06:27 -0400
parents 76737c0535b8
children 210d01022343
files setup.py sqlpython/test_sqlpyPlus.py
diffstat 2 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Thu Oct 23 16:20:45 2008 -0400
+++ b/setup.py	Tue Oct 28 15:06:27 2008 -0400
@@ -17,7 +17,7 @@
       url="https://twiki.cern.ch/twiki/bin/view/PSSGroup/SqlPython",
       packages=find_packages(),
       include_package_data=True,    
-      install_requires=['pyparsing','cmd2>=0.3.7','cx_Oracle','genshi>=0.5'],
+      install_requires=['pyparsing','cmd2>=0.4','cx_Oracle','genshi>=0.5'],
       keywords = 'client oracle database',
       license = 'MIT',
       platforms = ['any'],
--- a/sqlpython/test_sqlpyPlus.py	Thu Oct 23 16:20:45 2008 -0400
+++ b/sqlpython/test_sqlpyPlus.py	Tue Oct 28 15:06:27 2008 -0400
@@ -1,4 +1,4 @@
-import unittest, sys, tempfile, re, os.path
+import unittest, sys, tempfile, re, os.path, pyparsing
 from sqlpyPlus import *
 
 class Borg(object):
@@ -60,18 +60,18 @@
 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]
+def transcript(cmdapp, filename='test_sqlpyPlus.txt'):
+    tfile = open(filename)
+    txt = tfile.read()
+    tfile.close()
+    prompt = pyparsing.Suppress(pyparsing.lineStart + cmd.prompt)
+    continuationPrompt = pyparsing.Suppress(pyparsing.lineStart + cmd.continuationPrompt)
+    cmdtxtPattern = (prompt + pyparsing.restOfLine + pyparsing.ZeroOrMore(
+        pyparsing.lineEnd + continuationPrompt + pyparsing.restOfLine))("command")
+    previousStartPoint = 0
+    results = []
+    for onecmd in cmdtxtPattern.scanString(txt):
+        if len(results) > 0:
+            results[-1]['response'] = txt[previousStartPoint:onecmd[1]]
+        results.append({'command': ''.join(onecmd[0].command), 'response': txt[onecmd[2]:]})
+        previousStartPoint = onecmd[2]
\ No newline at end of file