PluginManager/PluginRepositoryDialog.py

changeset 6599
419f36a46608
parent 6156
ac12549e521a
child 6600
092cb8a3fc34
diff -r 20917d2d9b4b -r 419f36a46608 PluginManager/PluginRepositoryDialog.py
--- a/PluginManager/PluginRepositoryDialog.py	Sat Dec 01 10:06:10 2018 +0100
+++ b/PluginManager/PluginRepositoryDialog.py	Sat Dec 01 11:34:23 2018 +0100
@@ -36,6 +36,7 @@
 except ImportError:
     SSL_AVAILABLE = False
 
+import Globals
 import Utilities
 import Preferences
 
@@ -63,17 +64,30 @@
     PluginStatusLocalUpdate = 2
     PluginStatusRemoteUpdate = 3
     
-    def __init__(self, parent=None, external=False):
+    def __init__(self, pluginManager, parent=None):#, external=False):
         """
         Constructor
         
-        @param parent parent of this dialog (QWidget)
-        @param external flag indicating an instatiation as a main
-            window (boolean)
+        @param pluginManager reference to the plugin manager object
+        @type PluginManager
+        @param parent parent of this dialog
+        @type QWidget
+        @param external flag indicating an instantiation as a main
+            window
+        @type bool
         """
         super(PluginRepositoryWidget, self).__init__(parent)
         self.setupUi(self)
         
+        if pluginManager is None:
+            # started as external plug-in repository dialog
+            from .PluginManager import PluginManager
+            self.__pluginManager = PluginManager()
+            self.__external = True
+        else:
+            self.__pluginManager = pluginManager
+            self.__external = False
+        
         self.__updateButton = self.buttonBox.addButton(
             self.tr("Update"), QDialogButtonBox.ActionRole)
         self.__downloadButton = self.buttonBox.addButton(
@@ -113,8 +127,6 @@
         self.pluginRepositoryFile = \
             os.path.join(Utilities.getConfigDir(), "PluginRepository")
         
-        self.__external = external
-        
         # attributes for the network objects
         self.__networkManager = QNetworkAccessManager(self)
         self.__networkManager.proxyAuthenticationRequired.connect(
@@ -645,7 +657,18 @@
         # with the same pattern)
         archivesPattern = archive.rsplit('-', 1)[0] + "-*.zip"
         if len(glob.glob(archivesPattern)) == 0:
-            return PluginRepositoryWidget.PluginStatusNew
+            # Check against installed/loaded plug-ins
+            pluginName = filename.rsplit('-', 1)[0]
+            pluginDetails = self.__pluginManager.getPluginDetails(pluginName)
+            if pluginDetails is None:
+                return PluginRepositoryWidget.PluginStatusNew
+            pluginVersionTuple = Globals.versionToTuple(
+                pluginDetails["version"])[:3]
+            versionTuple = Globals.versionToTuple(version)[:3]
+            if pluginVersionTuple < versionTuple:
+                return PluginRepositoryWidget.PluginStatusRemoteUpdate
+            else:
+                return PluginRepositoryWidget.PluginStatusUpToDate
         
         # check, if the archive exists
         if not os.path.exists(archive):
@@ -663,21 +686,16 @@
         zipFile.close()
         
         if aversion == version:
-            if not self.__external:
-                # Check against installed/loaded plug-ins
-                pluginManager = e5App().getObject("PluginManager")
-                pluginName = filename.rsplit('-', 1)[0]
-                pluginDetails = pluginManager.getPluginDetails(pluginName)
-                if pluginDetails is None:
-                    return PluginRepositoryWidget.PluginStatusLocalUpdate
-                if version.count(".") >= 3:
-                    # cope for extended version numbers by ignoring
-                    # the extension
-                    version = ".".join(version.split(".", 3)[:3])
-                if pluginDetails["version"] < version:
-                    return PluginRepositoryWidget.PluginStatusLocalUpdate
-            
-            return PluginRepositoryWidget.PluginStatusUpToDate
+            # Check against installed/loaded plug-ins
+            pluginName = filename.rsplit('-', 1)[0]
+            pluginDetails = self.__pluginManager.getPluginDetails(pluginName)
+            if pluginDetails is None:
+                return PluginRepositoryWidget.PluginStatusLocalUpdate
+            if Globals.versionToTuple(pluginDetails["version"])[:3] < \
+               Globals.versionToTuple(version)[:3]:
+                return PluginRepositoryWidget.PluginStatusLocalUpdate
+            else:
+                return PluginRepositoryWidget.PluginStatusUpToDate
         else:
             return PluginRepositoryWidget.PluginStatusRemoteUpdate
     
@@ -781,11 +799,14 @@
     """
     Class for the dialog variant.
     """
-    def __init__(self, parent=None):
+    def __init__(self, pluginManager, parent=None):
         """
         Constructor
         
-        @param parent reference to the parent widget (QWidget)
+        @param pluginManager reference to the plugin manager object
+        @type PluginManager
+        @param parent reference to the parent widget
+        @type QWidget
         """
         super(PluginRepositoryDialog, self).__init__(parent)
         self.setSizeGripEnabled(True)
@@ -794,7 +815,7 @@
         self.__layout.setContentsMargins(0, 0, 0, 0)
         self.setLayout(self.__layout)
         
-        self.cw = PluginRepositoryWidget(self)
+        self.cw = PluginRepositoryWidget(pluginManager, self)
         size = self.cw.size()
         self.__layout.addWidget(self.cw)
         self.resize(size)
@@ -830,7 +851,7 @@
         @param parent reference to the parent widget (QWidget)
         """
         super(PluginRepositoryWindow, self).__init__(parent)
-        self.cw = PluginRepositoryWidget(self, external=True)
+        self.cw = PluginRepositoryWidget(None, self)
         size = self.cw.size()
         self.setCentralWidget(self.cw)
         self.resize(size)

eric ide

mercurial