UtilitiesPython2/Py2SyntaxChecker.py

changeset 3031
ed2eaa573ca5
parent 2998
95581102e03e
child 3150
42a8d3b5bd57
equal deleted inserted replaced
3030:4a0a82ddd9d2 3031:ed2eaa573ca5
44 except SyntaxError, detail: 44 except SyntaxError, detail:
45 index = "0" 45 index = "0"
46 code = "" 46 code = ""
47 error = "" 47 error = ""
48 lines = traceback.format_exception_only(SyntaxError, detail) 48 lines = traceback.format_exception_only(SyntaxError, detail)
49 match = re.match('\s*File "(.+)", line (\d+)', 49 match = re.match(
50 '\s*File "(.+)", line (\d+)',
50 lines[0].replace('<string>', '%s' % file)) 51 lines[0].replace('<string>', '%s' % file))
51 if match is not None: 52 if match is not None:
52 fn, line = match.group(1, 2) 53 fn, line = match.group(1, 2)
53 if lines[1].startswith('SyntaxError:'): 54 if lines[1].startswith('SyntaxError:'):
54 error = re.match('SyntaxError: (.+)', lines[1]).group(1) 55 error = re.match('SyntaxError: (.+)', lines[1]).group(1)

eric ide

mercurial