64 |
64 |
65 self.checkProgress.setVisible(False) |
65 self.checkProgress.setVisible(False) |
66 self.checkProgressLabel.setVisible(False) |
66 self.checkProgressLabel.setVisible(False) |
67 self.checkProgressLabel.setMaximumWidth(600) |
67 self.checkProgressLabel.setMaximumWidth(600) |
68 |
68 |
69 self.backgroundService = e5App().getObject('BackgroundService') |
69 self.internalServices = e5App().getObject('InternalServices') |
70 self.backgroundService.syntaxChecked.connect(self.processResult) |
70 self.internalServices.syntaxChecked.connect(self.__processResult) |
71 |
71 |
72 def __resort(self): |
72 def __resort(self): |
73 """ |
73 """ |
74 Private method to resort the tree. |
74 Private method to resort the tree. |
75 """ |
75 """ |
211 self.progress += 1 |
211 self.progress += 1 |
212 # Continue with next file |
212 # Continue with next file |
213 self.check() |
213 self.check() |
214 return |
214 return |
215 |
215 |
216 self.backgroundService.syntaxCheck( |
216 self.internalServices.syntaxCheck( |
217 self.filename, self.source, self.checkFlakes, |
217 self.filename, self.source, self.checkFlakes, |
218 self.ignoreStarImportWarnings) |
218 self.ignoreStarImportWarnings) |
219 |
219 |
220 def processResult( |
220 def __processResult( |
221 self, fn, nok, fname, line, index, code, error, warnings): |
221 self, fn, nok, fname, line, index, code, error, warnings): |
222 """ |
222 """ |
223 Slot which reports the resulting messages. |
223 Slot to display the reported messages. |
224 |
224 |
225 If checkFlakes is True, warnings contains a list of strings containing |
225 If checkFlakes is True, warnings contains a list of strings containing |
226 the warnings (marker, file name, line number, message) |
226 the warnings (marker, file name, line number, message) |
227 The values are only valid, if nok is False. |
227 The values are only valid, if nok is False. |
228 |
228 |
245 self.__createResultItem( |
245 self.__createResultItem( |
246 fname, line, index, error, code.strip(), False) |
246 fname, line, index, error, code.strip(), False) |
247 else: |
247 else: |
248 source = self.source.splitlines() |
248 source = self.source.splitlines() |
249 for warning in warnings: |
249 for warning in warnings: |
250 # TODO: Move to BackgroundService |
|
251 # Translate messages |
|
252 msg_args = warning.pop() |
|
253 translated = QApplication.translate( |
|
254 'py3Flakes', warning[-1]).format(*msg_args) |
|
255 # Avoid leading "u" at Python2 unicode strings |
|
256 if translated.startswith("u'"): |
|
257 translated = translated[1:] |
|
258 warning[3] = translated.replace(" u'", " '") |
|
259 |
|
260 self.noResults = False |
250 self.noResults = False |
261 scr_line = source[warning[2] - 1].strip() |
251 scr_line = source[warning[2] - 1].strip() |
262 self.__createResultItem( |
252 self.__createResultItem( |
263 warning[1], warning[2], 0, |
253 warning[1], warning[2], 0, |
264 warning[3], scr_line, True) |
254 warning[3], scr_line, True) |