Plugins/PluginCodeStyleChecker.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3456
96232974dcdb
parent 3446
5a670e55adbb
child 3515
1b8381afe38f
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
23 # Start-Of-Header 23 # Start-Of-Header
24 name = "Code Style Checker Plugin" 24 name = "Code Style Checker Plugin"
25 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 25 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
26 autoactivate = True 26 autoactivate = True
27 deactivateable = True 27 deactivateable = True
28 version = "5.4.0" 28 version = "5.5.0"
29 className = "CodeStyleCheckerPlugin" 29 className = "CodeStyleCheckerPlugin"
30 packageName = "__core__" 30 packageName = "__core__"
31 shortDescription = "Show the Python Code Style Checker dialog." 31 shortDescription = "Show the Python Code Style Checker dialog."
32 longDescription = """This plugin implements the Python Code Style""" \ 32 longDescription = """This plugin implements the Python Code Style""" \
33 """ Checker dialog. A PEP-8 checker is used to check Python source""" \ 33 """ Checker dialog. A PEP-8 checker is used to check Python source""" \
145 @return tuple of None and activation status (boolean) 145 @return tuple of None and activation status (boolean)
146 """ 146 """
147 menu = e5App().getObject("Project").getMenu("Checks") 147 menu = e5App().getObject("Project").getMenu("Checks")
148 if menu: 148 if menu:
149 self.__projectAct = E5Action( 149 self.__projectAct = E5Action(
150 self.trUtf8('Check Code Style'), 150 self.tr('Check Code Style'),
151 self.trUtf8('&Code Style...'), 0, 0, 151 self.tr('&Code Style...'), 0, 0,
152 self, 'project_check_pep8') 152 self, 'project_check_pep8')
153 self.__projectAct.setStatusTip( 153 self.__projectAct.setStatusTip(
154 self.trUtf8('Check code style.')) 154 self.tr('Check code style.'))
155 self.__projectAct.setWhatsThis(self.trUtf8( 155 self.__projectAct.setWhatsThis(self.tr(
156 """<b>Check Code Style...</b>""" 156 """<b>Check Code Style...</b>"""
157 """<p>This checks Python files for compliance to the""" 157 """<p>This checks Python files for compliance to the"""
158 """ code style conventions given in various PEPs.</p>""" 158 """ code style conventions given in various PEPs.</p>"""
159 )) 159 ))
160 self.__projectAct.triggered[()].connect( 160 self.__projectAct.triggered.connect(
161 self.__projectCodeStyleCheck) 161 self.__projectCodeStyleCheck)
162 e5App().getObject("Project").addE5Actions([self.__projectAct]) 162 e5App().getObject("Project").addE5Actions([self.__projectAct])
163 menu.addAction(self.__projectAct) 163 menu.addAction(self.__projectAct)
164 164
165 self.__editorAct = E5Action( 165 self.__editorAct = E5Action(
166 self.trUtf8('Check Code Style'), 166 self.tr('Check Code Style'),
167 self.trUtf8('&Code Style...'), 0, 0, 167 self.tr('&Code Style...'), 0, 0,
168 self, "") 168 self, "")
169 self.__editorAct.setWhatsThis(self.trUtf8( 169 self.__editorAct.setWhatsThis(self.tr(
170 """<b>Check Code Style...</b>""" 170 """<b>Check Code Style...</b>"""
171 """<p>This checks Python files for compliance to the""" 171 """<p>This checks Python files for compliance to the"""
172 """ code style conventions given in various PEPs.</p>""" 172 """ code style conventions given in various PEPs.</p>"""
173 )) 173 ))
174 self.__editorAct.triggered[()].connect(self.__editorCodeStyleCheck) 174 self.__editorAct.triggered.connect(self.__editorCodeStyleCheck)
175 175
176 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu) 176 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu)
177 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ 177 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\
178 .showMenu.connect(self.__projectBrowserShowMenu) 178 .showMenu.connect(self.__projectBrowserShowMenu)
179 e5App().getObject("ViewManager").editorOpenedEd.connect( 179 e5App().getObject("ViewManager").editorOpenedEd.connect(
241 e5App().getObject("Project").getProjectLanguage() in \ 241 e5App().getObject("Project").getProjectLanguage() in \
242 ["Python3", "Python2", "Python"]: 242 ["Python3", "Python2", "Python"]:
243 self.__projectBrowserMenu = menu 243 self.__projectBrowserMenu = menu
244 if self.__projectBrowserAct is None: 244 if self.__projectBrowserAct is None:
245 self.__projectBrowserAct = E5Action( 245 self.__projectBrowserAct = E5Action(
246 self.trUtf8('Check Code Style'), 246 self.tr('Check Code Style'),
247 self.trUtf8('&Code Style...'), 0, 0, 247 self.tr('&Code Style...'), 0, 0,
248 self, "") 248 self, "")
249 self.__projectBrowserAct.setWhatsThis(self.trUtf8( 249 self.__projectBrowserAct.setWhatsThis(self.tr(
250 """<b>Check Code Style...</b>""" 250 """<b>Check Code Style...</b>"""
251 """<p>This checks Python files for compliance to the""" 251 """<p>This checks Python files for compliance to the"""
252 """ code style conventions given in various PEPs.</p>""" 252 """ code style conventions given in various PEPs.</p>"""
253 )) 253 ))
254 self.__projectBrowserAct.triggered[()].connect( 254 self.__projectBrowserAct.triggered.connect(
255 self.__projectBrowserCodeStyleCheck) 255 self.__projectBrowserCodeStyleCheck)
256 if not self.__projectBrowserAct in menu.actions(): 256 if not self.__projectBrowserAct in menu.actions():
257 menu.addAction(self.__projectBrowserAct) 257 menu.addAction(self.__projectBrowserAct)
258 258
259 def __projectCodeStyleCheck(self): 259 def __projectCodeStyleCheck(self):
335 @param editor reference to the editor 335 @param editor reference to the editor
336 """ 336 """
337 if menuName == "Checks": 337 if menuName == "Checks":
338 if not self.__editorAct in menu.actions(): 338 if not self.__editorAct in menu.actions():
339 menu.addAction(self.__editorAct) 339 menu.addAction(self.__editorAct)
340 self.__editorAct.setEnabled(editor.getPyVersion()) 340 self.__editorAct.setEnabled(editor.isPyFile())
341 341
342 def __editorCodeStyleCheck(self): 342 def __editorCodeStyleCheck(self):
343 """ 343 """
344 Private slot to handle the code style check context menu action 344 Private slot to handle the code style check context menu action
345 of the editors. 345 of the editors.

eric ide

mercurial