|
From: Alex T. <ale...@us...> - 2004-10-10 23:03:25
|
Update of /cvsroot/pythoncard/PythonCard/tools/oneEditor/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11705/tools/oneEditor/modules Modified Files: scriptutils.py Log Message: Allow saveFile to work in CheckSyntax; fix syntax error production. Index: scriptutils.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/oneEditor/modules/scriptutils.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** scriptutils.py 3 Oct 2004 23:58:01 -0000 1.1 --- scriptutils.py 10 Oct 2004 23:02:09 -0000 1.2 *************** *** 12,23 **** # KEA 2002-05-08 # should probably refactor this so we're not passing around the background ! def CheckFile(background, pathName): what = "check" ! background.statusBar.text = what.capitalize()+'ing module...' try: f = open(pathName) except IOError, details: ! background.statusBar.text = "Cant open file '%s' - %s" % (pathName, details) return try: --- 12,25 ---- # KEA 2002-05-08 # should probably refactor this so we're not passing around the background + # AGT 2004-10-10 + # should refactor whis so we're not passing around 'statusBar' and 'document' ! def CheckFile(statusBar, document, pathName): what = "check" ! statusBar.text = what.capitalize()+'ing module...' try: f = open(pathName) except IOError, details: ! statusBar.text = "Cant open file '%s' - %s" % (pathName, details) return try: *************** *** 27,38 **** try: codeObj = compile(code, pathName,'exec') ! if RunTabNanny(background, pathName): #win32ui.SetStatusText("Python and the TabNanny successfully checked the file '"+os.path.basename(pathName)+"'") ! background.statusBar.text = "Python and the TabNanny successfully checked the file '"+os.path.basename(pathName)+"'" except SyntaxError: #background.statusBar.text = 'SyntaxError' ! _HandlePythonFailure(background, what, pathName) ! def RunTabNanny(background, filename): import cStringIO import tabnanny --- 29,40 ---- try: codeObj = compile(code, pathName,'exec') ! if RunTabNanny(statusBar, document, pathName): #win32ui.SetStatusText("Python and the TabNanny successfully checked the file '"+os.path.basename(pathName)+"'") ! statusBar.text = "Python and the TabNanny successfully checked the file '"+os.path.basename(pathName)+"'" except SyntaxError: #background.statusBar.text = 'SyntaxError' ! _HandlePythonFailure(statusBar, document, what, pathName) ! def RunTabNanny(statusBar, document, filename): import cStringIO import tabnanny *************** *** 52,56 **** lineno = data.split()[1] lineno = int(lineno) ! _JumpToPosition(background, filename, lineno) try: # Try and display whitespace #GetActiveEditControl().SCISetViewWS(1) --- 54,58 ---- lineno = data.split()[1] lineno = int(lineno) ! _JumpToPosition(document, filename, lineno) try: # Try and display whitespace #GetActiveEditControl().SCISetViewWS(1) *************** *** 59,73 **** pass #win32ui.SetStatusText("The TabNanny found trouble at line %d" % lineno) ! background.statusBar.text = "The TabNanny found trouble at line %d" % lineno except (IndexError, TypeError, ValueError): ! background.statusBar.text = "The tab nanny complained, but I cant see where!" print data return 0 return 1 ! def _JumpToPosition(background, fileName, lineno, col = 1): #JumpToDocument(fileName, lineno, col) #print fileName, lineno, col ! doc = background.components.document doc.GotoLine(lineno - 1) if col == 1: --- 61,75 ---- pass #win32ui.SetStatusText("The TabNanny found trouble at line %d" % lineno) ! statusBar.text = "The TabNanny found trouble at line %d" % lineno except (IndexError, TypeError, ValueError): ! statusBar.text = "The tab nanny complained, but I cant see where!" print data return 0 return 1 ! def _JumpToPosition(doc, fileName, lineno, col = 1): #JumpToDocument(fileName, lineno, col) #print fileName, lineno, col ! ###doc = document doc.GotoLine(lineno - 1) if col == 1: *************** *** 81,85 **** ! def _HandlePythonFailure(background, what, syntaxErrorPathName = None): typ, details, tb = sys.exc_info() if typ == SyntaxError: --- 83,87 ---- ! def _HandlePythonFailure(statusBar, document, what, syntaxErrorPathName = None): typ, details, tb = sys.exc_info() if typ == SyntaxError: *************** *** 88,96 **** if (not fileName or fileName =="<string>") and syntaxErrorPathName: fileName = syntaxErrorPathName ! _JumpToPosition(background, fileName, line, col) except (TypeError, ValueError): msg = str(details) #win32ui.SetStatusText('Failed to ' + what + ' - syntax error - %s' % msg) ! background.statusBar.text = 'Failed to ' + what + ' - syntax error - %s' % msg else: traceback.print_exc() --- 90,98 ---- if (not fileName or fileName =="<string>") and syntaxErrorPathName: fileName = syntaxErrorPathName ! _JumpToPosition(document, fileName, line, col) except (TypeError, ValueError): msg = str(details) #win32ui.SetStatusText('Failed to ' + what + ' - syntax error - %s' % msg) ! statusBar.text = 'Failed to ' + what + ' - syntax error - %s' % msg else: traceback.print_exc() *************** *** 108,115 **** try: msg, (fileName, line, col, text) = details ! _JumpToPosition(background, fileName, line, col) except: pass ! background.statusBar.text = 'Failed to ' + what + ' - ' + str(details) tb = None # Clean up a cycle. --- 110,117 ---- try: msg, (fileName, line, col, text) = details ! _JumpToPosition(document, fileName, line, col) except: pass ! statusBar.text = 'Failed to ' + what + ' - ' + str(details) tb = None # Clean up a cycle. |