def OnCheckComplete(self, data): """Callback for when compile check""" if len(data) != 2: util.Log("[PyTools][err] OnCheckComplete Invalid Data %s" % repr(data)) return path = data[0] err = data[1] if err: line = -1 # Python 3 outputs correct exception to stderr pat = re.compile('File "(.+)", line ([0-9]+)') matches = pat.findall(err) if len(matches) and len(matches[0]) == 2: match = matches[0] if match[1].isdigit(): line = int(matches[0][1]) # Python 2 py_compile outputs a tuple of args if line < 0: pat = re.compile("\('.*', ([0-9]+),") matchs = pat.findall(err) if len(matchs) and matchs[0].isdigit(): line = max(0, int(matchs[0]) - 1) if line >= 0: mw = wx.GetApp().GetActiveWindow() buff = PyStudioUtils.GetEditorForFile(mw, path) if buff: self._errdata[path] = (line, err) buff.AddMarker(ed_marker.ErrorMarker(), line) buff.GotoLine(line)
def OnFileLoad(self, msg): """Load File message""" editor = PyStudioUtils.GetEditorForFile(self._mw, msg.GetData()) if ToolConfig.GetConfigValue(ToolConfig.TLC_LINT_AUTORUN): wx.CallAfter(self._onfileaccess, editor) self.UpdateForEditor(editor, True) else: self.UpdateForEditor(editor)
def OnFileSaved(self, msg): """Performs file saved checks""" data = msg.GetData() if not data[0] or data[1] != synglob.ID_LANG_PYTHON: return buff = None for mw in wx.GetApp().GetMainWindows(): if mw.Id == msg.Context: buff = PyStudioUtils.GetEditorForFile(mw, data[0]) break if not buff: return buff.RemoveAllMarkers(ed_marker.ErrorMarker()) if data[0] in self._errdata: del self._errdata[data[0]] if ToolConfig.GetConfigValue(ToolConfig.TLC_COMPILE_ON_SAVE, True): # Run the compilation check RunAsyncTask("CompileCheck", self.OnCheckComplete, self.DoCompileCheck, data[0])
def OnFileSave(self, msg): """Load File message""" filename, tmp = msg.GetData() editor = PyStudioUtils.GetEditorForFile(self.mainwindow, filename) self._starttimer(editor)
def OnFileLoad(self, msg): """Load File message""" editor = PyStudioUtils.GetEditorForFile(self.mainwindow, msg.GetData()) self._starttimer(editor)