Fri, 02 Jan 2015 16:22:30 +0100
A few fixes and code style corrections.
--- a/PluginProjectWeb.py Thu Jan 01 17:14:39 2015 +0100 +++ b/PluginProjectWeb.py Fri Jan 02 16:22:30 2015 +0100 @@ -115,7 +115,7 @@ """ Public method to deactivate this plugin. """ - self.__e5project.unregisterProjectType("Django") + self.__e5project.unregisterProjectType("Web") self.__ui.showMenu.disconnect(self.__populateMenu) @@ -125,7 +125,7 @@ self.__editorClosed) for editor, acts in self.__editors.items(): -## editor.showMenu.disconnect(self.__editorShowMenu) + editor.showMenu.disconnect(self.__editorShowMenu) menu = editor.getMenu("Tools") if menu is not None: for act in acts: @@ -192,7 +192,8 @@ """ editor = e5App().getObject("ViewManager").activeWindow() selectionAvailable = bool(editor and editor.selectedText() != "") - isHtml = editor.getLanguage().lower().startswith("html") + isHtml = bool(editor and + editor.getLanguage().lower().startswith("html")) self.__html5ToCss3Act.setEnabled( selectionAvailable and BeautifulSoupAvailable and isHtml) @@ -211,14 +212,10 @@ if name != "Tools": return -## editor = e5App().getObject("ViewManager").activeWindow() -## if not menu.isEmpty(): menu.addSeparator() - act = menu.addMenu(self.__menu) - # TODO: check this -## act.setEnabled(editor is not None and editor.selectedText() != '') + menu.addMenu(self.__menu) def __editorOpened(self, editor): """ @@ -234,7 +231,7 @@ self.__editors[editor].append(act) act = menu.addMenu(self.__menu) self.__editors[editor].append(act) -## editor.showMenu.connect(self.__editorShowMenu) + editor.showMenu.connect(self.__editorShowMenu) def __editorClosed(self, editor): """ @@ -247,19 +244,25 @@ except KeyError: pass -## def __editorShowMenu(self, menuName, menu, editor): -## """ -## Private slot called, when the the editor context menu or a submenu is -## about to be shown. -## -## @param menuName name of the menu to be shown (string) -## @param menu reference to the menu (QMenu) -## @param editor reference to the editor -## """ -## if menuName == "Tools": -## # TODO: check this -## self.__menu.setEnabled(editor.selectedText() != '') -## + def __editorShowMenu(self, menuName, menu, editor): + """ + Private slot called, when the the editor context menu or a submenu is + about to be shown. + + @param menuName name of the menu to be shown (string) + @param menu reference to the menu (QMenu) + @param editor reference to the editor + """ + if menuName == "Tools": + if self.__menu.menuAction() not in menu.actions(): + # Re-add our menu + self.__editors[editor] = [] + if not menu.isEmpty(): + act = menu.addSeparator() + self.__editors[editor].append(act) + act = menu.addMenu(self.__menu) + self.__editors[editor].append(act) + def __htm5ToCss3(self): """ Private slot handling the HTML5 to CSS3 conversion.
--- a/PluginWeb.e4p Thu Jan 01 17:14:39 2015 +0100 +++ b/PluginWeb.e4p Fri Jan 02 16:22:30 2015 +0100 @@ -156,4 +156,83 @@ <FiletypeAssociation pattern="*.ui" type="FORMS"/> <FiletypeAssociation pattern="Ui_*.py" type="INTERFACES"/> </FiletypeAssociations> + <Checkers> + <CheckersParams> + <dict> + <key> + <string>Pep8Checker</string> + </key> + <value> + <dict> + <key> + <string>DocstringType</string> + </key> + <value> + <string>eric</string> + </value> + <key> + <string>ExcludeFiles</string> + </key> + <value> + <string>*/Ui_*.py</string> + </value> + <key> + <string>ExcludeMessages</string> + </key> + <value> + <string>W293, N802, N803, N807, N808, N821,E265</string> + </value> + <key> + <string>FixCodes</string> + </key> + <value> + <string></string> + </value> + <key> + <string>FixIssues</string> + </key> + <value> + <bool>False</bool> + </value> + <key> + <string>HangClosing</string> + </key> + <value> + <bool>False</bool> + </value> + <key> + <string>IncludeMessages</string> + </key> + <value> + <string></string> + </value> + <key> + <string>MaxLineLength</string> + </key> + <value> + <int>79</int> + </value> + <key> + <string>NoFixCodes</string> + </key> + <value> + <string>E501</string> + </value> + <key> + <string>RepeatMessages</string> + </key> + <value> + <bool>True</bool> + </value> + <key> + <string>ShowIgnored</string> + </key> + <value> + <bool>False</bool> + </value> + </dict> + </value> + </dict> + </CheckersParams> + </Checkers> </Project>
--- a/ProjectWeb/Html5ToCss3Converter.py Thu Jan 01 17:14:39 2015 +0100 +++ b/ProjectWeb/Html5ToCss3Converter.py Fri Jan 02 16:22:30 2015 +0100 @@ -77,7 +77,7 @@ os.linesep, indentation, random.choice(self.Placeholders) + os.linesep - if placeholders else os.linesep, + if placeholders else os.linesep, "}", os.linesep ) @@ -101,7 +101,7 @@ os.linesep, indentation, random.choice(self.Placeholders) + os.linesep - if placeholders else os.linesep, + if placeholders else os.linesep, "}", os.linesep ) @@ -125,7 +125,7 @@ os.linesep, indentation, random.choice(self.Placeholders) + os.linesep - if placeholders else os.linesep, + if placeholders else os.linesep, "}", os.linesep )