Mon, 13 Nov 2017 20:20:06 +0100
Continued to add support for Google protobuf protocol files.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DTDs/Project-6.0.dtd Mon Nov 13 20:20:06 2017 +0100 @@ -0,0 +1,174 @@ +<!-- This is the DTD for eric5's project file version 6.0 --> + +<!-- This is a copy of the Basic DTD --> +<!ELEMENT int (#PCDATA)> +<!ELEMENT long (#PCDATA)> +<!ELEMENT float (#PCDATA)> +<!ELEMENT complex (#PCDATA)> +<!ELEMENT bool (#PCDATA)> +<!ELEMENT string (#PCDATA)> +<!ELEMENT bytes (#PCDATA)> +<!ELEMENT bytearray (#PCDATA)> +<!ELEMENT none EMPTY> + +<!ELEMENT pickle (#PCDATA)> +<!ATTLIST pickle + method CDATA #REQUIRED + encoding CDATA #REQUIRED> + +<!ELEMENT key (int | long | float | complex | string | bytes)> +<!ELEMENT value (int | long | float | complex | bool | string | bytes | + bytearray | none | dict | tuple | list | set | frozenset | pickle)> + +<!ELEMENT dict (key, value)*> + +<!ELEMENT tuple (int | long | float | complex | bool | string | bytes | + bytearray | none | dict | tuple | list | set | frozenset | pickle)*> + +<!ELEMENT list (int | long | float | complex | bool | string | bytes | + bytearray | none | dict | tuple | list | set | frozenset | pickle)*> + +<!ELEMENT set (int | long | float | complex | bool | string | bytes | + bytearray | none | dict | tuple | list | set | frozenset | pickle)*> + +<!ELEMENT frozenset (int | long | float | complex | bool | string | bytes | + bytearray | none | dict | tuple | list | set | frozenset | pickle)*> +<!-- End of the Basic DTD --> + +<!ELEMENT ProgLanguage (#PCDATA)> +<!ATTLIST ProgLanguage + mixed CDATA #REQUIRED> + +<!ELEMENT ProjectType (#PCDATA)> + +<!ELEMENT Description (#PCDATA)> + +<!ELEMENT Version (#PCDATA)> + +<!ELEMENT Author (#PCDATA)> + +<!ELEMENT Email (#PCDATA)> + +<!ELEMENT TranslationPattern (#PCDATA)> + +<!ELEMENT TranslationsBinPath (#PCDATA)> + +<!ELEMENT Source (#PCDATA)> + +<!ELEMENT Sources (Source*)> + +<!ELEMENT Form (#PCDATA)> + +<!ELEMENT Forms (Form*)> + +<!ELEMENT Translation (#PCDATA)> + +<!ELEMENT Translations (Translation*)> + +<!ELEMENT TranslationException (#PCDATA)> + +<!ELEMENT TranslationExceptions (TranslationException*)> + +<!ELEMENT Resource (#PCDATA)> + +<!ELEMENT Resources (Resource*)> + +<!ELEMENT Interface (#PCDATA)> + +<!ELEMENT Interfaces (Interface*)> + +<!ELEMENT Protocol (#PCDATA)> + +<!ELEMENT Protocols (Protocol*)> + +<!ELEMENT Other (#PCDATA)> + +<!ELEMENT Others (Other*)> + +<!ELEMENT MainScript (#PCDATA)> + +<!ELEMENT VcsType (#PCDATA)> +<!ELEMENT VcsOptions (dict)> +<!ELEMENT VcsOtherData (dict)> + +<!ELEMENT Vcs (VcsType?, + VcsOptions?, + VcsOtherData?)> + +<!ELEMENT FiletypeAssociation EMPTY> +<!ATTLIST FiletypeAssociation + pattern CDATA #REQUIRED + type CDATA #REQUIRED> + +<!ELEMENT FiletypeAssociations (FiletypeAssociation*)> + +<!ELEMENT LexerAssociation EMPTY> +<!ATTLIST LexerAssociation + pattern CDATA #REQUIRED + lexer CDATA #REQUIRED> + +<!ELEMENT LexerAssociations (LexerAssociation*)> + +<!ELEMENT ProjectTypeSpecificData (dict)> + +<!ELEMENT ProjectTypeSpecific (ExtraData?)> + +<!ELEMENT DocumentationParams (dict)> + +<!ELEMENT Documentation (DocumentationParams?)> + +<!ELEMENT PackagersParams (dict)> + +<!ELEMENT Packagers (PackagersParams?)> + +<!ELEMENT CheckersParams (dict)> + +<!ELEMENT Checkers (CheckersParams?)> + +<!ELEMENT OtherToolsParams (dict)> + +<!ELEMENT OtherTools (OtherToolsParams?)> + +<!ELEMENT Language (#PCDATA)> + +<!ELEMENT ProjectWordList (#PCDATA)> + +<!ELEMENT ProjectExcludeList (#PCDATA)> + +<!ELEMENT Hash (#PCDATA)> + +<!ELEMENT Eol EMPTY> +<!ATTLIST Eol + index CDATA #REQUIRED> + +<!ELEMENT Project (Language, + ProjectWordList?, + ProjectExcludeList?, + Hash, + ProgLanguage, + ProjectType, + Description?, + Version?, + Author?, + Email?, + TranslationPattern?, + TranslationsBinPath?, + Eol?, + Sources, + Forms, + Translations, + TranslationExceptions?, + Resources, + Interfaces, + Others, + MainScript?, + Vcs, + FiletypeAssociations, + LexerAssociations?, + Extra?, + Documentation?, + Packagers?, + Checkers?, + OtherTools?)> +<!ATTLIST Project + version CDATA #REQUIRED>
--- a/E5XML/Config.py Sun Nov 12 19:42:02 2017 +0100 +++ b/E5XML/Config.py Mon Nov 13 20:20:06 2017 +0100 @@ -11,7 +11,7 @@ multiProjectFileFormatVersion = "5.1" # version number of the project file -projectFileFormatVersion = "5.1" +projectFileFormatVersion = "6.0" # version number of the user project file userProjectFileFormatVersion = "4.0"
--- a/E5XML/ProjectReader.py Sun Nov 12 19:42:02 2017 +0100 +++ b/E5XML/ProjectReader.py Mon Nov 13 20:20:06 2017 +0100 @@ -15,12 +15,11 @@ import Utilities -# TODO: add support for 'PROTOCOLS' (analog INTERFACES) class ProjectReader(XMLStreamReaderBase): """ Class for reading an XML project file. """ - supportedVersions = ["4.6", "5.0", "5.1"] + supportedVersions = ["4.6", "5.0", "5.1", "6.0"] def __init__(self, device, project): """ @@ -100,6 +99,8 @@ self.__readFiles("Resources", "Resource", "RESOURCES") elif self.name() == "Interfaces": self.__readFiles("Interfaces", "Interface", "INTERFACES") + elif self.name() == "Protocols": + self.__readFiles("Protocols", "Protocol", "PROTOCOLS") elif self.name() == "Others": self.__readFiles("Others", "Other", "OTHERS") elif self.name() == "MainScript":
--- a/E5XML/ProjectWriter.py Sun Nov 12 19:42:02 2017 +0100 +++ b/E5XML/ProjectWriter.py Mon Nov 13 20:20:06 2017 +0100 @@ -20,7 +20,6 @@ import Utilities -# TODO: add support for 'PROTOCOLS' (analog INTERFACES) class ProjectWriter(XMLStreamWriterBase): """ Class implementing the writer class for writing an XML project file. @@ -113,24 +112,28 @@ self.writeAttribute("index", str(int(self.pdata["EOL"]))) # do the sources - self.writeStartElement("Sources") - for name in sorted(self.pdata["SOURCES"]): - self.writeTextElement( - "Source", Utilities.fromNativeSeparators(name)) - self.writeEndElement() + if self.pdata["SOURCES"]: + self.writeStartElement("Sources") + for name in sorted(self.pdata["SOURCES"]): + self.writeTextElement( + "Source", Utilities.fromNativeSeparators(name)) + self.writeEndElement() # do the forms - self.writeStartElement("Forms") - for name in sorted(self.pdata["FORMS"]): - self.writeTextElement("Form", Utilities.fromNativeSeparators(name)) - self.writeEndElement() + if self.pdata["FORMS"]: + self.writeStartElement("Forms") + for name in sorted(self.pdata["FORMS"]): + self.writeTextElement( + "Form", Utilities.fromNativeSeparators(name)) + self.writeEndElement() # do the translations - self.writeStartElement("Translations") - for name in sorted(self.pdata["TRANSLATIONS"]): - self.writeTextElement( - "Translation", Utilities.fromNativeSeparators(name)) - self.writeEndElement() + if self.pdata["TRANSLATIONS"]: + self.writeStartElement("Translations") + for name in sorted(self.pdata["TRANSLATIONS"]): + self.writeTextElement( + "Translation", Utilities.fromNativeSeparators(name)) + self.writeEndElement() # do the translation exceptions if self.pdata["TRANSLATIONEXCEPTIONS"]: @@ -142,25 +145,36 @@ self.writeEndElement() # do the resources - self.writeStartElement("Resources") - for name in sorted(self.pdata["RESOURCES"]): - self.writeTextElement( - "Resource", Utilities.fromNativeSeparators(name)) - self.writeEndElement() + if self.pdata["RESOURCES"]: + self.writeStartElement("Resources") + for name in sorted(self.pdata["RESOURCES"]): + self.writeTextElement( + "Resource", Utilities.fromNativeSeparators(name)) + self.writeEndElement() # do the interfaces (IDL) - self.writeStartElement("Interfaces") - for name in sorted(self.pdata["INTERFACES"]): - self.writeTextElement( - "Interface", Utilities.fromNativeSeparators(name)) - self.writeEndElement() + if self.pdata["INTERFACES"]: + self.writeStartElement("Interfaces") + for name in sorted(self.pdata["INTERFACES"]): + self.writeTextElement( + "Interface", Utilities.fromNativeSeparators(name)) + self.writeEndElement() + + # do the protocols (protobuf) + if self.pdata["PROTOCOLS"]: + self.writeStartElement("Protocols") + for name in sorted(self.pdata["PROTOCOLS"]): + self.writeTextElement( + "Protocol", Utilities.fromNativeSeparators(name)) + self.writeEndElement() # do the others - self.writeStartElement("Others") - for name in sorted(self.pdata["OTHERS"]): - self.writeTextElement( - "Other", Utilities.fromNativeSeparators(name)) - self.writeEndElement() + if self.pdata["OTHERS"]: + self.writeStartElement("Others") + for name in sorted(self.pdata["OTHERS"]): + self.writeTextElement( + "Other", Utilities.fromNativeSeparators(name)) + self.writeEndElement() # do the main script if self.pdata["MAINSCRIPT"]:
--- a/Project/AddDirectoryDialog.py Sun Nov 12 19:42:02 2017 +0100 +++ b/Project/AddDirectoryDialog.py Mon Nov 13 20:20:06 2017 +0100 @@ -17,6 +17,7 @@ from .Ui_AddDirectoryDialog import Ui_AddDirectoryDialog +# TODO: add fileTypeFilter 'protocol' class AddDirectoryDialog(QDialog, Ui_AddDirectoryDialog): """ Class implementing a dialog to add files of a directory to the project.
--- a/Project/AddFileDialog.py Sun Nov 12 19:42:02 2017 +0100 +++ b/Project/AddFileDialog.py Mon Nov 13 20:20:06 2017 +0100 @@ -19,6 +19,7 @@ from .Ui_AddFileDialog import Ui_AddFileDialog +# TODO: add fileTypeFilter 'protocol' class AddFileDialog(QDialog, Ui_AddFileDialog): """ Class implementing a dialog to add a file to the project.
--- a/Project/Project.py Sun Nov 12 19:42:02 2017 +0100 +++ b/Project/Project.py Mon Nov 13 20:20:06 2017 +0100 @@ -43,7 +43,6 @@ import Utilities -# TODO: add support for 'PROTOCOLS' (analog INTERFACES) class Project(QObject): """ Class implementing the project management functionality. @@ -60,6 +59,8 @@ @signal projectSourceRemoved(str) emitted after a source was removed @signal projectInterfaceAdded(str) emitted after a new IDL file was added @signal projectInterfaceRemoved(str) emitted after a IDL file was removed + @signal projectProtocolAdded(str) emitted after a new proto file was added + @signal projectProtocolRemoved(str) emitted after a proto file was removed @signal projectResourceAdded(str) emitted after a new resource file was added @signal projectResourceRemoved(str) emitted after a resource was removed @@ -112,6 +113,8 @@ projectSourceRemoved = pyqtSignal(str) projectInterfaceAdded = pyqtSignal(str) projectInterfaceRemoved = pyqtSignal(str) + projectProtocolAdded = pyqtSignal(str) + projectProtocolRemoved = pyqtSignal(str) projectResourceAdded = pyqtSignal(str) projectResourceRemoved = pyqtSignal(str) projectOthersAdded = pyqtSignal(str) @@ -546,6 +549,9 @@ # IDL interfaces self.pdata["FILETYPES"]["*.idl"] = "INTERFACES" + # Protobuf Files + self.pdata["FILETYPES"]["*.proto"] = "PROTOCOLS" + # Forms if self.pdata["PROJECTTYPE"] in ["Qt4", "PyQt5", "E6Plugin", "PySide"]: @@ -765,6 +771,7 @@ self.__checkFilesExist("SOURCES") self.__checkFilesExist("FORMS") self.__checkFilesExist("INTERFACES") + self.__checkFilesExist("PROTOCOLS") self.__checkFilesExist("TRANSLATIONS") self.__checkFilesExist("RESOURCES") self.__checkFilesExist("OTHERS") @@ -773,6 +780,7 @@ for fn in self.pdata["SOURCES"] + \ self.pdata["FORMS"] + \ self.pdata["INTERFACES"] + \ + self.pdata["PROTOCOLS"] + \ self.pdata["RESOURCES"] + \ self.pdata["TRANSLATIONS"]: dn = os.path.dirname(fn) @@ -1460,7 +1468,8 @@ if filetype == "__IGNORE__": return - if filetype in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES"]: + if filetype in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", + "RESOURCES"]: if filetype == "SOURCES": if newfn not in self.pdata["SOURCES"]: self.pdata["SOURCES"].append(newfn) @@ -1486,6 +1495,15 @@ dirty = True else: updateModel and self.repopulateItem(newfn) + elif filetype == "PROTOCOLS": + if newfn not in self.pdata["PROTOCOLS"]: + self.pdata["PROTOCOLS"].append(newfn) + self.projectProtocolAdded.emit(newfn) + updateModel and \ + self.__model.addNewItem("PROTOCOLS", newfn) + dirty = True + else: + updateModel and self.repopulateItem(newfn) elif filetype == "RESOURCES": if newfn not in self.pdata["RESOURCES"]: self.pdata["RESOURCES"].append(newfn) @@ -1523,8 +1541,9 @@ Public slot used to add files to the project. @param fileTypeFilter filter to be used by the add file dialog - (string out of source, form, resource, interface, others) + @type str out of source, form, resource, interface, protocol, others @param startdir start directory for the selection dialog + @type str """ if startdir is None: startdir = self.ppath @@ -1674,8 +1693,9 @@ Public method used to add all files of a directory to the project. @param fileTypeFilter filter to be used by the add directory dialog - (string out of source, form, resource, interface, others) - @param startdir start directory for the selection dialog (string) + @type str out of source, form, resource, interface, protocol, others + @param startdir start directory for the selection dialog + @type str """ if startdir is None: startdir = self.ppath @@ -1747,6 +1767,12 @@ """ self.addFiles('interface') + def addProtoFiles(self): + """ + Public slot to add protocol files to the current project. + """ + self.addFiles('protocol') + def addResourceFiles(self): """ Public slot to add Qt resources to the current project. @@ -1779,6 +1805,13 @@ """ self.addDirectory('interface') + def addProtoDir(self): + """ + Public slot to add all protocol files of a directory to the current + project. + """ + self.addDirectory('protocol') + def addResourceDir(self): """ Public slot to add all Qt resource files of a directory to the current @@ -1856,6 +1889,7 @@ fn in self.pdata["FORMS"] or \ fn in self.pdata["TRANSLATIONS"] or \ fn in self.pdata["INTERFACES"] or \ + fn in self.pdata["PROTOCOLS"] or \ fn in self.pdata["RESOURCES"] or \ fn in self.pdata["OTHERS"]: self.renameFileInPdata(oldfn, newfn, isSourceFile) @@ -1892,7 +1926,8 @@ """ filelist = [] start = self.getRelativePath(start) - for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS"]: + for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", + "OTHERS"]: for entry in self.pdata[key][:]: if entry.startswith(start): filelist.append(os.path.join(self.ppath, entry)) @@ -1906,13 +1941,13 @@ # init data store for the reorganization newPdata = {} - for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS", - "TRANSLATIONS"]: + for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", + "OTHERS", "TRANSLATIONS"]: newPdata[key] = [] # iterate over all files checking for a reassignment - for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS", - "TRANSLATIONS"]: + for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", + "OTHERS", "TRANSLATIONS"]: for fn in self.pdata[key][:]: filetype = key bfn = os.path.basename(fn) @@ -1929,8 +1964,8 @@ if reorganized: # copy the reorganized files back to the project - for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", - "OTHERS", "TRANSLATIONS"]: + for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", + "RESOURCES", "OTHERS", "TRANSLATIONS"]: self.pdata[key] = newPdata[key][:] # repopulate the model @@ -1946,7 +1981,8 @@ """ olddn = self.getRelativePath(olddn) newdn = self.getRelativePath(newdn) - for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS"]: + for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", + "OTHERS"]: for entry in self.pdata[key][:]: if entry.startswith(olddn): entry = entry.replace(olddn, newdn) @@ -1964,7 +2000,8 @@ olddn = self.getRelativePath(olddn) newdn = self.getRelativePath(newdn) typeStrings = [] - for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS"]: + for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", + "OTHERS"]: for entry in self.pdata[key][:]: if entry.startswith(olddn): if key not in typeStrings: @@ -2006,6 +2043,9 @@ elif fn in self.pdata["INTERFACES"]: self.pdata["INTERFACES"].remove(fn) self.projectInterfaceRemoved.emit(fn) + elif fn in self.pdata["PROTOCOLS"]: + self.pdata["PROTOCOLS"].remove(fn) + self.projectProtocolRemoved.emit(fn) elif fn in self.pdata["RESOURCES"]: self.pdata["RESOURCES"].remove(fn) self.projectResourceRemoved.emit(fn) @@ -2039,7 +2079,7 @@ dn2 = dn + os.sep else: dn2 = dn - for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", + for key in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", "TRANSLATIONS", ]: for entry in self.pdata[key][:]: if entry.startswith(dn2): @@ -2131,6 +2171,7 @@ if fn in self.pdata["SOURCES"] or \ fn in self.pdata["FORMS"] or \ fn in self.pdata["INTERFACES"] or \ + fn in self.pdata["PROTOCOLS"] or \ fn in self.pdata["RESOURCES"] or \ fn in self.pdata["OTHERS"]: return True @@ -3117,7 +3158,7 @@ Public method to get the file entries of the given type. @param fileType project file type (one of SOURCES, FORMS, RESOURCES, - INTERFACES, OTHERS, TRANSLATIONS) + INTERFACES, PROTOCOLS, OTHERS, TRANSLATIONS) @type str @param normalized flag indicating normalized file names are wanted @type boolean @@ -3126,7 +3167,7 @@ @exception ValueError raised when an unsupported file type is given """ if fileType not in ["SOURCES", "FORMS", "RESOURCES", "INTERFACES", - "OTHERS", "TRANSLATIONS"]: + "PROTOCOLS", "OTHERS", "TRANSLATIONS"]: raise ValueError("Given file type has incorrect value.") if normalized: @@ -3448,7 +3489,7 @@ @param fn filename to be checked (string) @return flag indicating membership (boolean) """ - for group in ["SOURCES", "FORMS", "INTERFACES", + for group in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS", "RESOURCES", "TRANSLATIONS", "OTHERS"]: if self.__checkProjectFileGroup(fn, group): return True @@ -3516,6 +3557,18 @@ """ return self.__checkProjectFileGroup(fn, "INTERFACES") + def isProjectProtocol(self, fn): + """ + Public method used to check, if the passed in filename belongs to the + project protocols. + + @param fn filename to be checked + @type str + @return flag indicating membership + @rtype bool + """ + return self.__checkProjectFileGroup(fn, "PROTOCOLS") + def isProjectResource(self, fn): """ Public method used to check, if the passed in filename belongs to the @@ -3654,8 +3707,9 @@ 'Search new files in the project directory.')) act.setWhatsThis(self.tr( """<b>Search new files...</b>""" - """<p>This searches for new files (sources, *.ui, *.idl) in""" - """ the project directory and registered subdirectories.</p>""" + """<p>This searches for new files (sources, *.ui, *.idl,""" + """ *.proto) in the project directory and registered""" + """ subdirectories.</p>""" )) act.triggered.connect(self.__searchNewFiles) self.actions.append(act) @@ -3711,11 +3765,11 @@ self.tr('Show the project filetype associations')) self.filetypesAct.setWhatsThis(self.tr( """<b>Filetype Associations...</b>""" - """<p>This shows a dialog to edit the filetype associations of""" + """<p>This shows a dialog to edit the file type associations of""" """ the project. These associations determine the type""" - """ (source, form, interface or others) with a filename""" - """ pattern. They are used when adding a file to the project""" - """ and when performing a search for new files.</p>""" + """ (source, form, interface, protocol or others) with a""" + """ filename pattern. They are used when adding a file to the""" + """ project and when performing a search for new files.</p>""" )) self.filetypesAct.triggered.connect( self.__showFiletypeAssociations) @@ -4308,6 +4362,8 @@ fn not in self.pdata["FORMS"]) or \ (filetype == "INTERFACES" and fn not in self.pdata["INTERFACES"]) or \ + (filetype == "PROTOCOLS" and + fn not in self.pdata["PROTOCOLS"]) or \ (filetype == "RESOURCES" and fn not in self.pdata["RESOURCES"]) or \ (filetype == "OTHERS" and fn not in self.pdata["OTHERS"]): @@ -4877,7 +4933,7 @@ # build the list of entries lst_ = [] for key in ["SOURCES", "FORMS", "RESOURCES", "TRANSLATIONS", - "INTERFACES", "OTHERS"]: + "INTERFACES", "PROTOCOLS", "OTHERS"]: lst_.extend(self.pdata[key]) lst = [] for entry in lst_:
--- a/Project/ProjectBrowser.py Sun Nov 12 19:42:02 2017 +0100 +++ b/Project/ProjectBrowser.py Mon Nov 13 20:20:06 2017 +0100 @@ -348,6 +348,8 @@ self.pfBrowser.selectFile(fn) elif self.project.isProjectInterface(fn): self.piBrowser.selectFile(fn) + elif self.project.isProjectProtocol(fn): + self.ppBrowser.selectFile(fn) def handleEditorLineChanged(self, fn, lineno): """
--- a/Project/ProjectProtocolsBrowser.py Sun Nov 12 19:42:02 2017 +0100 +++ b/Project/ProjectProtocolsBrowser.py Mon Nov 13 20:20:06 2017 +0100 @@ -67,7 +67,6 @@ "protoc.exe" or "protoc" if not Utilities.isinpath(self.__protoc): self.__protoc = None - self.omniidl = self.__protoc # TODO: remove this line ProjectBaseBrowser.__init__(self, project, ProjectBrowserProtocolsType, parent) @@ -87,7 +86,6 @@ project.prepareRepopulateItem.connect(self._prepareRepopulateItem) project.completeRepopulateItem.connect(self._completeRepopulateItem) - # TODO: continue from here def _createPopupMenus(self): """ Protected overloaded method to generate the popup menu. @@ -98,12 +96,12 @@ self.dirMultiMenuActions = [] self.sourceMenu = QMenu(self) - if self.omniidl is not None: + if self.__protoc is not None: self.sourceMenu.addAction( - self.tr('Compile interface'), self.__compileInterface) + self.tr('Compile protocol'), self.__compileProtocol) self.sourceMenu.addAction( - self.tr('Compile all interfaces'), - self.__compileAllInterfaces) + self.tr('Compile all protocols'), + self.__compileAllProtocols) self.sourceMenu.addAction(self.tr('Open'), self._openItem) self.sourceMenu.addSeparator() act = self.sourceMenu.addAction( @@ -117,10 +115,10 @@ self.menuActions.append(act) self.sourceMenu.addSeparator() self.sourceMenu.addAction( - self.tr('Add interfaces...'), self.__addInterfaceFiles) + self.tr('Add protocols...'), self.__addProtocolFiles) self.sourceMenu.addAction( - self.tr('Add interfaces directory...'), - self.__addInterfacesDirectory) + self.tr('Add protocols directory...'), + self.__addProtocolsDirectory) self.sourceMenu.addSeparator() self.sourceMenu.addAction( self.tr('Copy Path to Clipboard'), self._copyToClipboard) @@ -132,22 +130,22 @@ self.sourceMenu.addSeparator() self.sourceMenu.addAction(self.tr('Configure...'), self._configure) self.sourceMenu.addAction( - self.tr('Configure CORBA...'), self.__configureCorba) + self.tr('Configure Protobuf...'), self.__configureProtobuf) self.menu = QMenu(self) - if self.omniidl is not None: + if self.__protoc is not None: self.menu.addAction( - self.tr('Compile interface'), self.__compileInterface) + self.tr('Compile protocol'), self.__compileProtocol) self.menu.addAction( - self.tr('Compile all interfaces'), - self.__compileAllInterfaces) + self.tr('Compile all protocols'), + self.__compileAllProtocols) self.menu.addAction(self.tr('Open'), self._openItem) self.menu.addSeparator() self.menu.addAction( - self.tr('Add interfaces...'), self.__addInterfaceFiles) + self.tr('Add protocols...'), self.__addProtocolFiles) self.menu.addAction( - self.tr('Add interfaces directory...'), - self.__addInterfacesDirectory) + self.tr('Add protocols directory...'), + self.__addProtocolsDirectory) self.menu.addSeparator() self.menu.addAction( self.tr('Expand all directories'), self._expandAllDirs) @@ -156,18 +154,18 @@ self.menu.addSeparator() self.menu.addAction(self.tr('Configure...'), self._configure) self.menu.addAction( - self.tr('Configure CORBA...'), self.__configureCorba) + self.tr('Configure Protobuf...'), self.__configureProtobuf) self.backMenu = QMenu(self) - if self.omniidl is not None: + if self.__protoc is not None: self.backMenu.addAction( - self.tr('Compile all interfaces'), - self.__compileAllInterfaces) + self.tr('Compile all protocols'), + self.__compileAllProtocols) self.backMenu.addSeparator() self.backMenu.addAction( - self.tr('Add interfaces...'), self.project.addIdlFiles) + self.tr('Add protocols...'), self.project.addProtoFiles) self.backMenu.addAction( - self.tr('Add interfaces directory...'), self.project.addIdlDir) + self.tr('Add protocols directory...'), self.project.addProtoDir) self.backMenu.addSeparator() self.backMenu.addAction( self.tr('Expand all directories'), self._expandAllDirs) @@ -176,15 +174,15 @@ self.backMenu.addSeparator() self.backMenu.addAction(self.tr('Configure...'), self._configure) self.backMenu.addAction( - self.tr('Configure CORBA...'), self.__configureCorba) + self.tr('Configure Protobuf...'), self.__configureProtobuf) self.backMenu.setEnabled(False) # create the menu for multiple selected files self.multiMenu = QMenu(self) - if self.omniidl is not None: + if self.__protoc is not None: self.multiMenu.addAction( - self.tr('Compile interfaces'), - self.__compileSelectedInterfaces) + self.tr('Compile protocols'), + self.__compileSelectedProtocols) self.multiMenu.addAction(self.tr('Open'), self._openItem) self.multiMenu.addSeparator() act = self.multiMenu.addAction( @@ -201,13 +199,13 @@ self.multiMenu.addSeparator() self.multiMenu.addAction(self.tr('Configure...'), self._configure) self.multiMenu.addAction( - self.tr('Configure CORBA...'), self.__configureCorba) + self.tr('Configure Protobuf...'), self.__configureProtobuf) self.dirMenu = QMenu(self) - if self.omniidl is not None: + if self.__protoc is not None: self.dirMenu.addAction( - self.tr('Compile all interfaces'), - self.__compileAllInterfaces) + self.tr('Compile all protocols'), + self.__compileAllProtocols) self.dirMenu.addSeparator() act = self.dirMenu.addAction( self.tr('Remove from project'), self._removeFile) @@ -217,10 +215,10 @@ self.dirMenuActions.append(act) self.dirMenu.addSeparator() self.dirMenu.addAction( - self.tr('Add interfaces...'), self.__addInterfaceFiles) + self.tr('Add protocols...'), self.__addProtocolFiles) self.dirMenu.addAction( - self.tr('Add interfaces directory...'), - self.__addInterfacesDirectory) + self.tr('Add protocols directory...'), + self.__addProtocolsDirectory) self.dirMenu.addSeparator() self.dirMenu.addAction( self.tr('Copy Path to Clipboard'), self._copyToClipboard) @@ -232,18 +230,18 @@ self.dirMenu.addSeparator() self.dirMenu.addAction(self.tr('Configure...'), self._configure) self.dirMenu.addAction( - self.tr('Configure CORBA...'), self.__configureCorba) + self.tr('Configure Protobuf...'), self.__configureProtobuf) self.dirMultiMenu = QMenu(self) - if self.omniidl is not None: + if self.__protoc is not None: self.dirMultiMenu.addAction( - self.tr('Compile all interfaces'), - self.__compileAllInterfaces) + self.tr('Compile all protocols'), + self.__compileAllProtocols) self.dirMultiMenu.addSeparator() self.dirMultiMenu.addAction( - self.tr('Add interfaces...'), self.project.addIdlFiles) + self.tr('Add protocols...'), self.project.addProtoFiles) self.dirMultiMenu.addAction( - self.tr('Add interfaces directory...'), self.project.addIdlDir) + self.tr('Add protocols directory...'), self.project.addProtoDir) self.dirMultiMenu.addSeparator() self.dirMultiMenu.addAction( self.tr('Expand all directories'), self._expandAllDirs) @@ -252,8 +250,8 @@ self.dirMultiMenu.addSeparator() self.dirMultiMenu.addAction( self.tr('Configure...'), self._configure) - self.dirMultiMenu.addAction(self.tr('Configure CORBA...'), - self.__configureCorba) + self.dirMultiMenu.addAction(self.tr('Configure Protobuf...'), + self.__configureProtobuf) self.sourceMenu.aboutToShow.connect(self.__showContextMenu) self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti) @@ -375,9 +373,9 @@ self.sourceFile[str, int].emit( itm.fileName(), itm.attributeObject().lineno) - def __addInterfaceFiles(self): + def __addProtocolFiles(self): """ - Private method to add interface files to the project. + Private method to add protocol files to the project. """ itm = self.model().item(self.currentIndex()) if isinstance(itm, ProjectBrowserFileItem) or \ @@ -389,11 +387,11 @@ dn = itm.dirName() else: dn = None - self.project.addFiles('interface', dn) + self.project.addFiles('protocol', dn) - def __addInterfacesDirectory(self): + def __addProtocolsDirectory(self): """ - Private method to add interface files of a directory to the project. + Private method to add protocol files of a directory to the project. """ itm = self.model().item(self.currentIndex()) if isinstance(itm, ProjectBrowserFileItem) or \ @@ -405,7 +403,7 @@ dn = itm.dirName() else: dn = None - self.project.addDirectory('interface', dn) + self.project.addDirectory('protocol', dn) def __deleteFile(self): """ @@ -425,8 +423,8 @@ DeleteFilesConfirmationDialog dlg = DeleteFilesConfirmationDialog( self.parent(), - self.tr("Delete interfaces"), - self.tr("Do you really want to delete these interfaces from" + self.tr("Delete Protocols"), + self.tr("Do you really want to delete these protocol files from" " the project?"), files) @@ -442,7 +440,7 @@ def __readStdout(self): """ Private slot to handle the readyReadStandardOutput signal of the - omniidl process. + protoc process. """ if self.compileProc is None: return @@ -451,7 +449,7 @@ self.compileProc.setReadChannel(QProcess.StandardOutput) while self.compileProc and self.compileProc.canReadLine(): - s = 'omniidl: ' + s = 'protoc: ' output = str(self.compileProc.readLine(), ioEncoding, 'replace') s += output self.appendStdout.emit(s) @@ -459,7 +457,7 @@ def __readStderr(self): """ Private slot to handle the readyReadStandardError signal of the - omniidl process. + protoc process. """ if self.compileProc is None: return @@ -468,63 +466,59 @@ self.compileProc.setReadChannel(QProcess.StandardError) while self.compileProc and self.compileProc.canReadLine(): - s = 'omniidl: ' + s = 'protoc: ' error = str(self.compileProc.readLine(), ioEncoding, 'replace') s += error self.appendStderr.emit(s) - def __compileIDLDone(self, exitCode, exitStatus): + def __compileProtocolDone(self, exitCode, exitStatus): """ - Private slot to handle the finished signal of the omniidl process. + Private slot to handle the finished signal of the protoc process. @param exitCode exit code of the process (integer) @param exitStatus exit status of the process (QProcess.ExitStatus) """ - self.compileRunning = False + self.__compileRunning = False ui = e5App().getObject("UserInterface") if exitStatus == QProcess.NormalExit and exitCode == 0: - path = os.path.dirname(self.idlFile) - poaList = glob.glob(os.path.join(path, "*__POA")) - npoaList = [f.replace("__POA", "") for f in poaList] - fileList = glob.glob(os.path.join(path, "*_idl.py")) - for directory in poaList + npoaList: - fileList += Utilities.direntries(directory, True, "*.py") + path = os.path.dirname(self.__protoFile) + fileList = glob.glob(os.path.join(path, "*_pb2.py")) for file in fileList: self.project.appendFile(file) if not self.noDialog and not ui.notificationsEnabled(): E5MessageBox.information( self, - self.tr("Interface Compilation"), + self.tr("Protocol Compilation"), self.tr( - "The compilation of the interface file was" + "The compilation of the protocol file was" " successful.")) else: ui.showNotification( - UI.PixmapCache.getPixmap("corba48.png"), - self.tr("Interface Compilation"), + UI.PixmapCache.getPixmap("protobuf48.png"), + self.tr("Protocol Compilation"), self.tr( - "The compilation of the interface file was" + "The compilation of the protocol file was" " successful.")) else: if not self.noDialog: E5MessageBox.information( self, - self.tr("Interface Compilation"), + self.tr("Protocol Compilation"), self.tr( - "The compilation of the interface file failed.")) + "The compilation of the protocol file failed.")) else: ui.showNotification( - UI.PixmapCache.getPixmap("corba48.png"), - self.tr("Interface Compilation"), + UI.PixmapCache.getPixmap("protobuf48.png"), + self.tr("Protocol Compilation"), self.tr( - "The compilation of the interface file failed.")) + "The compilation of the protocol file failed.")) self.compileProc = None - def __compileIDL(self, fn, noDialog=False, progress=None): + def __compileProto(self, fn, noDialog=False, progress=None): """ - Private method to compile a .idl file to python. + Private method to compile a .proto file to Python. - @param fn filename of the .idl file to be compiled (string) + @param fn filename of the .proto file to be compiled (string) @param noDialog flag indicating silent operations (boolean) @param progress reference to the progress dialog (E5ProgressDialog) @return reference to the compile process (QProcess) @@ -532,26 +526,26 @@ self.compileProc = QProcess() args = [] - args.append("-bpython") - args.append("-I.") + fn = os.path.join(self.project.ppath, fn) + self.__protoFile = fn - fn = os.path.join(self.project.ppath, fn) - self.idlFile = fn - args.append("-C{0}".format(os.path.dirname(fn))) + srcPath = os.path.dirname(fn) + args.append("--proto_path={0}".format(srcPath)) + args.append("--python_out={0}".format(srcPath)) args.append(fn) - self.compileProc.finished.connect(self.__compileIDLDone) + self.compileProc.finished.connect(self.__compileProtocolDone) self.compileProc.readyReadStandardOutput.connect(self.__readStdout) self.compileProc.readyReadStandardError.connect(self.__readStderr) self.noDialog = noDialog - self.compileProc.start(self.omniidl, args) + self.compileProc.start(self.__protoc, args) procStarted = self.compileProc.waitForStarted(5000) if procStarted: - self.compileRunning = True + self.__compileRunning = True return self.compileProc else: - self.compileRunning = False + self.__compileRunning = False if progress is not None: progress.cancel() E5MessageBox.critical( @@ -560,39 +554,39 @@ self.tr( '<p>Could not start {0}.<br>' 'Ensure that it is in the search path.</p>' - ).format(self.omniidl)) + ).format(self.__protoc)) return None - def __compileInterface(self): + def __compileProtocol(self): """ - Private method to compile an interface to python. + Private method to compile a protocol to Python. """ - if self.omniidl is not None: + if self.__protoc is not None: itm = self.model().item(self.currentIndex()) fn2 = itm.fileName() fn = self.project.getRelativePath(fn2) - self.__compileIDL(fn) + self.__compileProto(fn) - def __compileAllInterfaces(self): + def __compileAllProtocols(self): """ - Private method to compile all interfaces to python. + Private method to compile all protocols to Python. """ - if self.omniidl is not None: - numIDLs = len(self.project.pdata["INTERFACES"]) + if self.__protoc is not None: + numProtos = len(self.project.pdata["PROTOCOLS"]) progress = E5ProgressDialog( - self.tr("Compiling interfaces..."), - self.tr("Abort"), 0, numIDLs, - self.tr("%v/%m Interfaces"), self) + self.tr("Compiling Protocols..."), + self.tr("Abort"), 0, numProtos, + self.tr("%v/%m Protocols"), self) progress.setModal(True) progress.setMinimumDuration(0) - progress.setWindowTitle(self.tr("Interfaces")) + progress.setWindowTitle(self.tr("Protocols")) i = 0 - for fn in self.project.pdata["INTERFACES"]: + for fn in self.project.pdata["PROTOCOLS"]: progress.setValue(i) if progress.wasCanceled(): break - proc = self.__compileIDL(fn, True, progress) + proc = self.__compileProto(fn, True, progress) if proc is not None: while proc.state() == QProcess.Running: QApplication.processEvents() @@ -602,32 +596,32 @@ break i += 1 - progress.setValue(numIDLs) + progress.setValue(numProtos) - def __compileSelectedInterfaces(self): + def __compileSelectedProtocols(self): """ - Private method to compile selected interfaces to python. + Private method to compile selected protocols to Python. """ - if self.omniidl is not None: + if self.__protoc is not None: items = self.getSelectedItems() files = [self.project.getRelativePath(itm.fileName()) for itm in items] - numIDLs = len(files) + numProtos = len(files) progress = E5ProgressDialog( - self.tr("Compiling interfaces..."), - self.tr("Abort"), 0, numIDLs, - self.tr("%v/%m Interfaces"), self) + self.tr("Compiling Protocols..."), + self.tr("Abort"), 0, numProtos, + self.tr("%v/%m Protocols"), self) progress.setModal(True) progress.setMinimumDuration(0) - progress.setWindowTitle(self.tr("Interfaces")) + progress.setWindowTitle(self.tr("Protocols")) i = 0 for fn in files: progress.setValue(i) if progress.wasCanceled(): break - proc = self.__compileIDL(fn, True, progress) + proc = self.__compileProto(fn, True, progress) if proc is not None: while proc.state() == QProcess.Running: QApplication.processEvents() @@ -637,10 +631,10 @@ break i += 1 - progress.setValue(numIDLs) + progress.setValue(numProtos) - def __configureCorba(self): + def __configureProtobuf(self): """ Private method to open the configuration dialog. """ - e5App().getObject("UserInterface").showPreferences("corbaPage") + e5App().getObject("UserInterface").showPreferences("protobufPage")
--- a/QScintilla/Editor.py Sun Nov 12 19:42:02 2017 +0100 +++ b/QScintilla/Editor.py Mon Nov 13 20:20:06 2017 +0100 @@ -1414,6 +1414,10 @@ @keyparam propagate flag indicating to propagate the change (boolean) @keyparam pyname name of the pygments lexer to use (string) """ + # clear all warning and syntax error markers + self.clearSyntaxError() + self.clearWarnings() + self.menuActs["MonospacedFont"].setChecked(False) self.__lexerReset = False @@ -1426,7 +1430,7 @@ if initTextDisplay: self.__setTextDisplay() - # set the autocompletion and calltips function + # set the auto-completion and call-tips function self.__setAutoCompletion() self.__setCallTips() @@ -1599,13 +1603,16 @@ if pyname: self.apiLanguage = "Pygments|{0}".format(pyname) else: - # Change API language for lexer where QScintilla reports - # an abbreviated name. - self.apiLanguage = self.lexer_.language() - if self.apiLanguage == "POV": - self.apiLanguage = "Povray" - elif self.apiLanguage == "PO": - self.apiLanguage = "Gettext" + if language == "Protocol": + self.apiLanguage = language + else: + # Change API language for lexer where QScintilla reports + # an abbreviated name. + self.apiLanguage = self.lexer_.language() + if self.apiLanguage == "POV": + self.apiLanguage = "Povray" + elif self.apiLanguage == "PO": + self.apiLanguage = "Gettext" self.setLexer(self.lexer_) self.__setMarginsDisplay() if self.lexer_.lexer() == "container" or self.lexer_.lexer() is None:
--- a/QScintilla/Lexers/__init__.py Sun Nov 12 19:42:02 2017 +0100 +++ b/QScintilla/Lexers/__init__.py Mon Nov 13 20:20:06 2017 +0100 @@ -130,6 +130,9 @@ "lexerPOV.png"], "Properties": [QCoreApplication.translate('Lexers', "Properties"), 'dummy.ini', "lexerProperties.png"], + "Protocol": [QCoreApplication.translate('Lexers', + "Protocol (protobuf)"), + 'dummy.proto', "protobuf.png"], "Python2": [QCoreApplication.translate('Lexers', "Python2"), 'dummy.py', "lexerPython.png"], "Python3": [QCoreApplication.translate('Lexers', "Python3"), @@ -334,6 +337,9 @@ from .LexerMarkdown import LexerMarkdown return LexerMarkdown(parent) + elif language == "Protocol": + return __getPygmentsLexer(parent, name="Protocol Buffer") + elif language in LexerRegistry: return LexerRegistry[language][2](parent) @@ -395,6 +401,9 @@ 'IDL Files (*.idl)'), QCoreApplication.translate( 'Lexers', + 'Protocol Files (*.proto)'), + QCoreApplication.translate( + 'Lexers', 'C Files (*.h *.c)'), QCoreApplication.translate( 'Lexers', @@ -579,6 +588,9 @@ "IDL Files (*.idl)"), QCoreApplication.translate( 'Lexers', + 'Protocol Files (*.proto)'), + QCoreApplication.translate( + 'Lexers', "C Files (*.c)"), QCoreApplication.translate( 'Lexers', @@ -881,6 +893,7 @@ '*.e6q': "XML", '*.e6s': "XML", '*.e6t': "XML", + '*.proto': "Protocol", } if QSCINTILLA_VERSION() >= 0x020802: