Project/Project.py

changeset 5382
5b772524f302
parent 5359
396145256ada
child 5389
9b1c800daff3
diff -r 46fc897c5ac0 -r 5b772524f302 Project/Project.py
--- a/Project/Project.py	Sun Dec 18 12:58:22 2016 +0100
+++ b/Project/Project.py	Sun Dec 18 13:42:41 2016 +0100
@@ -4793,6 +4793,32 @@
     ## Below are the plugin development related methods
     #########################################################################
     
+    def __pluginVersionToTuple(self, versionStr):
+        """
+        Private method to convert a plug-in version string into a version
+        tuple.
+        
+        @param versionStr version string to be converted
+        @type str
+        @return version info as a tuple
+        @rtype tuple of int and str
+        """
+        vParts = []
+        if "-" in versionStr:
+            versionStr, additional = versionStr.split("-", 1)
+        else:
+            additional = ""
+        for part in versionStr.split("."):
+            try:
+                vParts.append(int(part))
+            except ValueError:
+                vParts.append(part)
+        
+        if additional:
+            vParts.append(additional)
+        
+        return tuple(vParts)
+    
     def __pluginCreatePkgList(self):
         """
         Private slot to create a PKGLIST file needed for archive file creation.
@@ -4919,14 +4945,19 @@
             
             lines = names.splitlines()
             archiveName = ""
+            archiveVersion=""
             names = []
             for line in lines:
                 if line.startswith(";"):
+                    line = line[1:].strip()
                     # it's a comment possibly containing a directive
                     # supported directives are:
                     # - archive_name= defines the name of the archive
-                    if line[1:].strip().startswith("archive_name="):
-                        archiveName = line[1:].split("=")[1]
+                    # - archive_version= defines the version of the archive
+                    if line.startswith("archive_name="):
+                        archiveName = line.split("=")[1]
+                    elif line.startswith("archive_version="):
+                        archiveVersion = line.split("=")[1]
                 else:
                     names.append(line)
             names = sorted(names)
@@ -4968,6 +4999,11 @@
                                 version = self.__pluginExtractVersion(
                                     os.path.join(self.ppath,
                                                  self.pdata["MAINSCRIPT"]))
+                                if archiveVersion and (
+                                    self.__pluginVersionToTuple(version) <
+                                    self.__pluginVersionToTuple(archiveVersion)
+                                ):
+                                    version = archiveVersion
                     except OSError as why:
                         E5MessageBox.critical(
                             self.ui,

eric ide

mercurial