[go: up one dir, main page]

Menu

[r13]: / bin / SyntaxChecker.py  Maximize  Restore  History

Download this file

43 lines (32 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wx
class SyntaxDoctor:
def CheckSyntax(self, event, text_id):
cur_doc = wx.FindWindowById(text_id)
file_nm = cur_doc.SaveTarget
print file_nm
try:
ctext = cur_doc.GetText()
ctext = ctext.replace('\r\n', '\n').replace('\r', '\n')
compile(ctext, file_nm, 'exec')
say_ok = wx.MessageDialog(None,
"No errors have been detected.", "Syntax Check")
if say_ok.ShowModal() == wx.ID_OK:
say_ok.Destroy()
except Exception, e:
ln_num = ""
excstr = str(e)
try:
for c in exctr:
if int(c):
ln_num += str(c)
n = int(ln_num)
cur_doc.ScrollToLine(n)
cur_doc.GotoLine(n)
except:
say_error = wx.MessageDialog(None, 'Error:' + excstr,
'Error Found')
if say_error.ShowModal() == wx.ID_OK:
say_error.Destroy()
SyntaxDoc = SyntaxDoctor()