69
70
"""<p>This checks all Python files"""
70
71
""" for bad indentations using tabnanny.</p>"""
72
self.tabnannyAct.connectIt(SIGNAL('activated()'),
73
self.tabnannyAct.connectIt(SIGNAL('triggered(bool)'),
73
74
self.projectOrBrowser.handleTabnanny)
74
75
self.actions.append(self.tabnannyAct)
76
self.pylintAct = E3Action(self.trUtf8('Run PyLint'),
77
self.trUtf8('Run &PyLint...'),0,0,
78
self,'project_check_pylint')
79
self.pylintAct.setStatusTip(\
80
self.trUtf8('Check project, packages or modules with pylint.'))
81
self.pylintAct.setWhatsThis(self.trUtf8(
82
"""<b>Run PyLint...</b>"""
83
"""<p>This checks the project, packages or modules using pylint.</p>"""
85
self.pylintAct.connectIt(SIGNAL('activated()'),
86
self.projectOrBrowser.handlePyLint)
87
self.actions.append(self.pylintAct)
89
self.pylintShowAct = E3Action(self.trUtf8('Show PyLint Dialog'),
90
self.trUtf8('Show Py&Lint Dialog...'),0,0,
91
self,'project_check_pylintshow')
92
self.pylintShowAct.setStatusTip(\
93
self.trUtf8('Show the PyLint dialog with the results of the last run.'))
94
self.pylintShowAct.setWhatsThis(self.trUtf8(
95
"""<b>Show PyLint Dialog...</b>"""
96
"""<p>This shows the PyLint dialog with the results of the last run.</p>"""
98
self.pylintShowAct.connectIt(SIGNAL('activated()'),
99
self.handlePyLintShow)
100
self.actions.append(self.pylintShowAct)
77
self.pylint.initActions()
102
79
def initMenu(self):
104
Private method called to build the project packagers submenu.
81
Public method called to build the Checkers submenu.
106
83
@return the menu or None
108
menu = QPopupMenu(self.parent())
109
menu.insertTearOffHandle()
86
menu.setTearOffEnabled(True)
111
88
self.checkSyntaxAct.addTo(menu)
112
89
self.tabnannyAct.addTo(menu)
113
menu.insertSeparator()
114
self.pylintAct.addTo(menu)
115
self.pylintShowAct.addTo(menu)
117
# entry for cxfreeze is only activated if it is accessible
119
if sys.platform == "win32":
121
self.pylintAct.setEnabled(Utilities.isinpath(exe))
91
self.pylint.initMenu(menu)
123
93
# connect the aboutToShow signal
124
self.connect(menu, SIGNAL('aboutToShow()'), self.handleShowMenu)
94
self.connect(menu, SIGNAL('aboutToShow()'), self.__showMenu)
128
98
def getActions(self):
130
100
Public method to get a list of all actions.
132
@return list of all actions (list of E3Action)
134
return self.actions[:]
136
def handleTabnanny(self, files):
138
Private slot used to check the project files for bad indentations.
102
@return list of all actions (list of E4Action)
104
return self.actions[:] + self.pylint.getActions()
106
def __showMenu(self):
108
Private slot to handle the aboutToShow signal of the menu.
110
self.pylint.checkActions()
112
def closeAllWindows(self):
114
Public method to close all windows.
116
self.tabnannyDialog and self.tabnannyDialog.close()
117
self.syntaxcheckDialog and self.syntaxcheckDialog.close()
118
self.pylint.closeAllWindows()
120
def tabnanny(self, files):
122
Public slot used to check the project files for bad indentations.
140
124
@param files File or list of files or directory to be checked
141
125
(string or list of strings)
143
self.tabnannyDialog = TabnannyDialog(qApp.mainWidget().getViewManager())
127
self.tabnannyDialog = TabnannyDialog()
144
128
self.tabnannyDialog.show()
145
129
self.tabnannyDialog.start(files)
147
def handleSyntaxCheck(self, files):
131
def syntaxCheck(self, files):
149
Private slot used to check the project files for bad syntax.
133
Public slot used to check the project files for bad syntax.
151
135
@param files File or list of files or directory to be checked
152
136
(string or list of strings)
154
self.syntaxcheckDialog = SyntaxCheckerDialog(qApp.mainWidget().getViewManager())
138
self.syntaxcheckDialog = SyntaxCheckerDialog()
155
139
self.syntaxcheckDialog.show()
156
140
self.syntaxcheckDialog.start(files)
158
def handlePyLint(self, project, mpName):
142
############################################################################
143
## Public interface to PyLint
144
############################################################################
146
def pyLint(self, project, mpName):
160
148
Public method used to perform a PyLint run.
162
150
@param project reference to the Project object
163
151
@param mpName name of module or package to be checked (string or QString)
165
if len(project.pdata['PYLINTPARMS']):
166
parms = copy.deepcopy(project.pdata['PYLINTPARMS'][0])
169
dlg = PyLintConfigDialog(project.ppath, parms)
170
if dlg.exec_loop() == QDialog.Accepted:
171
args, parms = dlg.generateParameters()
173
# test for changes of selected parameters and save the in the project
174
# 1. there were none, now there are
175
if len(project.pdata['PYLINTPARMS']) == 0 and len(parms) > 0:
176
project.pdata['PYLINTPARMS'] = [copy.deepcopy(parms)]
178
# 2. there were some, now there aren't
179
elif len(project.pdata['PYLINTPARMS']) > 0 and len(parms) == 0:
180
project.pdata['PYLINTPARMS'] = []
182
# 3. there were some and still are
184
if parms != project.pdata['PYLINTPARMS'][0]:
185
project.pdata['PYLINTPARMS'] = [copy.deepcopy(parms)]
189
self.pylintDialog = PyLintExecDialog()
191
reportFile = parms['reportFile']
194
res = self.pylintDialog.start(args, mpName, reportFile, project.ppath)
196
self.pylintDialog.show()
198
def handlePyLintShow(self):
200
Private slot to show the PyLint dialog with the results of the last run.
202
if self.pylintDialog is not None:
203
self.pylintDialog.show()
205
def handleShowMenu(self):
207
Private slot to handle the aboutToShow signal of the menu.
209
self.pylintShowAct.setEnabled(self.pylintDialog is not None)
153
self.pylint.pyLint(project, mpName)