PyLint/PyLintConfigDialog.py

changeset 28
1dae294006e8
parent 24
b01348dd84d5
child 30
de4b620a6e88
equal deleted inserted replaced
27:ff4bcced7a34 28:1dae294006e8
2 2
3 # Copyright (c) 2005 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2005 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a dialog to configure the PyLint process 7 Module implementing a dialog to configure the PyLint process.
8 """ 8 """
9 9
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 10 from __future__ import unicode_literals # __IGNORE_WARNING__
11 try: 11 try:
12 str = unicode # __IGNORE_WARNING__ 12 str = unicode # __IGNORE_WARNING__
29 import Utilities 29 import Utilities
30 30
31 31
32 class PyLintConfigDialog(QDialog, Ui_PyLintConfigDialog): 32 class PyLintConfigDialog(QDialog, Ui_PyLintConfigDialog):
33 """ 33 """
34 Class implementing a dialog to configure the PyLint process 34 Class implementing a dialog to configure the PyLint process.
35 """ 35 """
36 def __init__(self, ppath, exe, parms, version): 36 def __init__(self, ppath, exe, parms, version):
37 """ 37 """
38 Constructor 38 Constructor
39 39
76 self.designCheckBox.setChecked(self.parameters['enableDesign']) 76 self.designCheckBox.setChecked(self.parameters['enableDesign'])
77 self.exceptionsCheckBox.setChecked(self.parameters['enableExceptions']) 77 self.exceptionsCheckBox.setChecked(self.parameters['enableExceptions'])
78 self.formatCheckBox.setChecked(self.parameters['enableFormat']) 78 self.formatCheckBox.setChecked(self.parameters['enableFormat'])
79 self.importsCheckBox.setChecked(self.parameters['enableImports']) 79 self.importsCheckBox.setChecked(self.parameters['enableImports'])
80 self.metricsCheckBox.setChecked(self.parameters['enableMetrics']) 80 self.metricsCheckBox.setChecked(self.parameters['enableMetrics'])
81 self.miscellaneousCheckBox.setChecked(self.parameters['enableMiscellaneous']) 81 self.miscellaneousCheckBox.setChecked(
82 self.parameters['enableMiscellaneous'])
82 self.newstyleCheckBox.setChecked(self.parameters['enableNewstyle']) 83 self.newstyleCheckBox.setChecked(self.parameters['enableNewstyle'])
83 self.similaritiesCheckBox.setChecked(self.parameters['enableSimilarities']) 84 self.similaritiesCheckBox.setChecked(
85 self.parameters['enableSimilarities'])
84 self.typecheckCheckBox.setChecked(self.parameters['enableTypecheck']) 86 self.typecheckCheckBox.setChecked(self.parameters['enableTypecheck'])
85 self.variablesCheckBox.setChecked(self.parameters['enableVariables']) 87 self.variablesCheckBox.setChecked(self.parameters['enableVariables'])
86 self.loggingCheckBox.setChecked(self.parameters['enableLogging']) 88 self.loggingCheckBox.setChecked(self.parameters['enableLogging'])
87 self.stringFormatCheckBox.setChecked(self.parameters['enableStringFormat']) 89 self.stringFormatCheckBox.setChecked(
90 self.parameters['enableStringFormat'])
88 91
89 # initialize messages tab 92 # initialize messages tab
90 self.enabledMessagesEdit.setText(self.parameters['enabledMessages']) 93 self.enabledMessagesEdit.setText(self.parameters['enabledMessages'])
91 self.disabledMessagesEdit.setText(self.parameters['disabledMessages']) 94 self.disabledMessagesEdit.setText(self.parameters['disabledMessages'])
92 95
136 to set the QProcess arguments for the pylint call and 139 to set the QProcess arguments for the pylint call and
137 a list containing the non default parameters. The second 140 a list containing the non default parameters. The second
138 list can be passed back upon object generation to overwrite 141 list can be passed back upon object generation to overwrite
139 the default settings. 142 the default settings.
140 143
141 <b>Note</b>: The arguments list contains the name of the pylint executable as 144 <b>Note</b>: The arguments list contains the name of the pylint
142 the first parameter. 145 executable as the first parameter.
143 146
144 @return a tuple of the commandline parameters and non default parameters 147 @return a tuple of the commandline parameters and non default
145 (list of strings, dictionary) 148 parameters (list of strings, dictionary)
146 """ 149 """
147 parms = {} 150 parms = {}
148 args = [] 151 args = []
149 152
150 # 1. the program name 153 # 1. the program name
243 startWith = self.ppath 246 startWith = self.ppath
244 config = E5FileDialog.getOpenFileName( 247 config = E5FileDialog.getOpenFileName(
245 self, 248 self,
246 self.trUtf8("Select configuration file"), 249 self.trUtf8("Select configuration file"),
247 startWith, 250 startWith,
248 self.trUtf8("Configuration Files (*.cfg *.cnf *.rc);;All Files (*)")) 251 self.trUtf8("Configuration Files (*.cfg *.cnf *.rc);;"
252 "All Files (*)"))
249 if config: 253 if config:
250 self.configfileEdit.setText(Utilities.toNativeSeparators(config)) 254 self.configfileEdit.setText(Utilities.toNativeSeparators(config))
251 255
252 @pyqtSlot() 256 @pyqtSlot()
253 def on_reportfileButton_clicked(self): 257 def on_reportfileButton_clicked(self):
282 286
283 # get data of checkers tab 287 # get data of checkers tab
284 self.parameters['enableBasic'] = self.basicCheckBox.isChecked() 288 self.parameters['enableBasic'] = self.basicCheckBox.isChecked()
285 self.parameters['enableClasses'] = self.classesCheckBox.isChecked() 289 self.parameters['enableClasses'] = self.classesCheckBox.isChecked()
286 self.parameters['enableDesign'] = self.designCheckBox.isChecked() 290 self.parameters['enableDesign'] = self.designCheckBox.isChecked()
287 self.parameters['enableExceptions'] = self.exceptionsCheckBox.isChecked() 291 self.parameters['enableExceptions'] = \
292 self.exceptionsCheckBox.isChecked()
288 self.parameters['enableFormat'] = self.formatCheckBox.isChecked() 293 self.parameters['enableFormat'] = self.formatCheckBox.isChecked()
289 self.parameters['enableImports'] = self.importsCheckBox.isChecked() 294 self.parameters['enableImports'] = self.importsCheckBox.isChecked()
290 self.parameters['enableMetrics'] = self.metricsCheckBox.isChecked() 295 self.parameters['enableMetrics'] = self.metricsCheckBox.isChecked()
291 self.parameters['enableMiscellaneous'] = self.miscellaneousCheckBox.isChecked() 296 self.parameters['enableMiscellaneous'] = \
297 self.miscellaneousCheckBox.isChecked()
292 self.parameters['enableNewstyle'] = self.newstyleCheckBox.isChecked() 298 self.parameters['enableNewstyle'] = self.newstyleCheckBox.isChecked()
293 self.parameters['enableSimilarities'] = self.similaritiesCheckBox.isChecked() 299 self.parameters['enableSimilarities'] = \
300 self.similaritiesCheckBox.isChecked()
294 self.parameters['enableTypecheck'] = self.typecheckCheckBox.isChecked() 301 self.parameters['enableTypecheck'] = self.typecheckCheckBox.isChecked()
295 self.parameters['enableVariables'] = self.variablesCheckBox.isChecked() 302 self.parameters['enableVariables'] = self.variablesCheckBox.isChecked()
296 self.parameters['enableLogging'] = self.loggingCheckBox.isChecked() 303 self.parameters['enableLogging'] = self.loggingCheckBox.isChecked()
297 self.parameters['enableStringFormat'] = self.stringFormatCheckBox.isChecked() 304 self.parameters['enableStringFormat'] = \
305 self.stringFormatCheckBox.isChecked()
298 306
299 # get data of messages tab 307 # get data of messages tab
300 self.parameters['enabledMessages'] = ','.join( 308 self.parameters['enabledMessages'] = ','.join(
301 [m.strip() for m in self.enabledMessagesEdit.text().split(',')]) 309 [m.strip() for m in self.enabledMessagesEdit.text().split(',')])
302 self.parameters['disabledMessages'] = ','.join( 310 self.parameters['disabledMessages'] = ','.join(
303 [m.strip() for m in self.disabledMessagesEdit.text().split(',')]) 311 [m.strip() for m in self.disabledMessagesEdit.text().split(',')])
304 312
305 # call the accept slot of the base class 313 # call the accept slot of the base class
306 super(PyLintConfigDialog, self).accept() 314 super(PyLintConfigDialog, self).accept()
307 315
308 ############################################################################ 316 ###########################################################################
309 ## Methods below are needed to generate a configuration file template 317 ## Methods below are needed to generate a configuration file template
310 ############################################################################ 318 ###########################################################################
311 319
312 @pyqtSlot() 320 @pyqtSlot()
313 def on_configButton_clicked(self): 321 def on_configButton_clicked(self):
314 """ 322 """
315 Public slot to handle the generation of a sample configuration. 323 Public slot to handle the generation of a sample configuration.
329 self.pylintProc.start(self.lint, args) 337 self.pylintProc.start(self.lint, args)
330 procStarted = self.pylintProc.waitForStarted() 338 procStarted = self.pylintProc.waitForStarted()
331 if procStarted: 339 if procStarted:
332 e5App().getObject("ViewManager").enableEditorsCheckFocusIn(False) 340 e5App().getObject("ViewManager").enableEditorsCheckFocusIn(False)
333 else: 341 else:
334 E5MessageBox.critical(self, 342 E5MessageBox.critical(
343 self,
335 self.trUtf8('Process Generation Error'), 344 self.trUtf8('Process Generation Error'),
336 self.trUtf8( 345 self.trUtf8(
337 'Could not start {0}.<br>' 346 'Could not start {0}.<br>'
338 'Ensure that it is in the search path.' 347 'Ensure that it is in the search path.'
339 ).format(self.lint)) 348 ).format(self.lint))
354 aw.setLanguage('dummy.rc') 363 aw.setLanguage('dummy.rc')
355 self.reject() 364 self.reject()
356 365
357 def __readStdout(self): 366 def __readStdout(self):
358 """ 367 """
359 Private slot to handle the readyReadStandardOutput signal of the pylint process. 368 Private slot to handle the readyReadStandardOutput signal of the
369 pylint process.
360 """ 370 """
361 if self.pylintProc is None: 371 if self.pylintProc is None:
362 return 372 return
363 self.pylintProc.setReadChannel(QProcess.StandardOutput) 373 self.pylintProc.setReadChannel(QProcess.StandardOutput)
364 374
365 while self.pylintProc and self.pylintProc.canReadLine(): 375 while self.pylintProc and self.pylintProc.canReadLine():
366 line = str(self.pylintProc.readLine(), self.__ioEncoding, "replace").rstrip() 376 line = str(self.pylintProc.readLine(), self.__ioEncoding,
377 "replace").rstrip()
367 self.buf += line + os.linesep 378 self.buf += line + os.linesep
368 379
369 def __readStderr(self): 380 def __readStderr(self):
370 """ 381 """
371 Private slot to handle the readyReadStandardError signal of the pylint process. 382 Private slot to handle the readyReadStandardError signal of the
383 pylint process.
372 """ 384 """
373 if self.pylintProc is None: 385 if self.pylintProc is None:
374 return 386 return
375 self.pylintProc.setReadChannel(QProcess.StandardError) 387 self.pylintProc.setReadChannel(QProcess.StandardError)
376 while self.pylintProc and self.pylintProc.canReadLine(): 388 while self.pylintProc and self.pylintProc.canReadLine():

eric ide

mercurial