PyLint/PyLintExecDialog.py

changeset 11
a8e908641c20
parent 10
398979610d9b
child 15
0fc414663bd9
equal deleted inserted replaced
10:398979610d9b 11:a8e908641c20
27 Class implementing a dialog to show the results of the PyLint run. 27 Class implementing a dialog to show the results of the PyLint run.
28 28
29 This class starts a QProcess and displays a dialog that 29 This class starts a QProcess and displays a dialog that
30 shows the results of the PyLint command process. 30 shows the results of the PyLint command process.
31 """ 31 """
32 filenameRole = Qt.UserRole + 1
33
32 def __init__(self, parent=None): 34 def __init__(self, parent=None):
33 """ 35 """
34 Constructor 36 Constructor
35 37
36 @param parent parent widget of this dialog (QWidget) 38 @param parent parent widget of this dialog (QWidget)
129 self.htmlOutput = False 131 self.htmlOutput = False
130 self.parsedOutput = False 132 self.parsedOutput = False
131 self.noResults = True 133 self.noResults = True
132 134
133 self.buf = "" 135 self.buf = ""
136 self.__lastFileItem = None
134 137
135 self.process.start(program, args) 138 self.process.start(program, args)
136 procStarted = self.process.waitForStarted() 139 procStarted = self.process.waitForStarted()
137 if not procStarted: 140 if not procStarted:
138 E5MessageBox.critical(None, 141 E5MessageBox.critical(None,
237 @param file filename of file (string) 240 @param file filename of file (string)
238 @param line linenumber of message (integer or string) 241 @param line linenumber of message (integer or string)
239 @param type_ type of message (string) 242 @param type_ type of message (string)
240 @param message message text (string) 243 @param message message text (string)
241 """ 244 """
242 itm = QTreeWidgetItem(self.messageList, [ 245 if self.__lastFileItem is None or self.__lastFileItem.text(0) != file:
243 file, str(line), type_, message]) 246 matchFlags = Qt.MatchFixedString
244 itm.setTextAlignment(1, Qt.AlignRight) 247 if not Utilities.isWindowsPlatform():
245 itm.setTextAlignment(2, Qt.AlignHCenter) 248 matchFlags |= Qt.MatchCaseSensitive
249
250 itmList = self.messageList.findItems(file, matchFlags)
251 if itmList:
252 self.__lastFileItem = itmList[0]
253 else:
254 # It's a new file
255 self.__lastFileItem = QTreeWidgetItem(self.messageList, [file])
256 self.__lastFileItem.setFirstColumnSpanned(True)
257 self.__lastFileItem.setExpanded(True)
258 self.__lastFileItem.setData(0, self.filenameRole, file)
259
260 itm = QTreeWidgetItem(self.__lastFileItem, [str(line), type_, message])
261 itm.setTextAlignment(0, Qt.AlignRight)
262 itm.setTextAlignment(1, Qt.AlignHCenter)
263 itm.setData(0, self.filenameRole, file)
246 264
247 def __readParseStdout(self): 265 def __readParseStdout(self):
248 """ 266 """
249 Private slot to handle the readyReadStandardOutput signal for parseable output. 267 Private slot to handle the readyReadStandardOutput signal for parseable output.
250 268
302 @param column column the item was activated in (integer) 320 @param column column the item was activated in (integer)
303 """ 321 """
304 if self.noResults: 322 if self.noResults:
305 return 323 return
306 324
307 fn = os.path.join(self.pathname, itm.text(0)) 325 if itm.parent():
308 lineno = int(itm.text(1)) 326 fn = os.path.join(self.pathname, itm.data(0, self.filenameRole))
309 327 lineno = int(itm.text(0))
310 e5App().getObject("ViewManager").openSourceFile(fn, lineno) 328
311 # TODO: set warning markers 329 vm = e5App().getObject("ViewManager")
330 vm.openSourceFile(fn, lineno)
331 editor = vm.getOpenEditor(fn)
332 editor.toggleFlakesWarning(lineno, True,
333 "{0} | {1}".format(itm.text(1), itm.text(2)))
334 else:
335 fn = os.path.join(self.pathname, itm.data(0, self.filenameRole))
336 vm = e5App().getObject("ViewManager")
337 vm.openSourceFile(fn)
338 editor = vm.getOpenEditor(fn)
339 for index in range(itm.childCount()):
340 citm = itm.child(index)
341 lineno = int(citm.text(0))
342 editor.toggleFlakesWarning(lineno, True,
343 "{0} | {1}".format(citm.text(1), citm.text(2)))
312 344
313 def __writeReport(self): 345 def __writeReport(self):
314 """ 346 """
315 Private slot to write the report to a report file. 347 Private slot to write the report to a report file.
316 """ 348 """

eric ide

mercurial