Fixed an issue cleaning up the plug-in download area. maintenance

Fri, 17 Nov 2017 18:51:40 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 17 Nov 2017 18:51:40 +0100
branch
maintenance
changeset 5982
af0d2f9dfa21
parent 5981
2f2c988c359e
child 5983
a604749f4fcc

Fixed an issue cleaning up the plug-in download area.
(grafted from 3bc24855b2543a2a983b9c9020e16fa3cdc5f535)

PluginManager/PluginRepositoryDialog.py file | annotate | diff | comparison | revisions
diff -r 2f2c988c359e -r af0d2f9dfa21 PluginManager/PluginRepositoryDialog.py
--- a/PluginManager/PluginRepositoryDialog.py	Thu Nov 09 18:31:34 2017 +0100
+++ b/PluginManager/PluginRepositoryDialog.py	Fri Nov 17 18:51:40 2017 +0100
@@ -14,6 +14,7 @@
 import os
 import zipfile
 import glob
+import re
 
 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QFile, QIODevice, QUrl, \
     QProcess, QPoint, QCoreApplication
@@ -877,22 +878,31 @@
         if not os.path.isfile(os.path.join(downloadPath, pluginFile)):
             continue
         
-        pluginName = pluginFile.rsplit("-", 1)[0]
+        pluginName, pluginVersion = \
+            pluginFile.replace(".zip", "").rsplit("-", 1)
+        pluginVersionList = re.split("[._-]", pluginVersion)
+        for index in range(len(pluginVersionList)):
+            try:
+                pluginVersionList[index] = int(pluginVersionList[index])
+            except ValueError:
+                # use default of 0
+                pluginVersionList[index] = 0
+        
         if pluginName not in downloads:
             downloads[pluginName] = []
-        downloads[pluginName].append(pluginFile)
+        downloads[pluginName].append((pluginFile, tuple(pluginVersionList)))
     
     # step 2: delete old entries
     hiddenPlugins = Preferences.getPluginManager("HiddenPlugins")
     for pluginName in downloads:
-        downloads[pluginName].sort()
+        downloads[pluginName].sort(key=lambda x: x[1])
     
         if pluginName in hiddenPlugins and \
                 not Preferences.getPluginManager("KeepHidden"):
-            removeFiles = downloads[pluginName]
+            removeFiles = downloads[pluginName][0]
         else:
-            removeFiles = downloads[pluginName][
-                :-Preferences.getPluginManager("KeepGenerations")]
+            removeFiles = [f[0] for f in downloads[pluginName][
+                :-Preferences.getPluginManager("KeepGenerations")]]
         for removeFile in removeFiles:
             try:
                 os.remove(os.path.join(downloadPath, removeFile))

eric ide

mercurial