--- a/eric6/PluginManager/PluginInstallDialog.py Sat Sep 21 17:41:22 2019 +0200 +++ b/eric6/PluginManager/PluginInstallDialog.py Sat Sep 21 18:30:02 2019 +0200 @@ -20,8 +20,10 @@ import urlparse as parse # __IGNORE_WARNING__ from PyQt5.QtCore import pyqtSlot, Qt, QDir, QFileInfo -from PyQt5.QtWidgets import QWidget, QDialogButtonBox, QAbstractButton, \ - QApplication, QDialog, QVBoxLayout +from PyQt5.QtWidgets import ( + QWidget, QDialogButtonBox, QAbstractButton, QApplication, QDialog, + QVBoxLayout +) from E5Gui import E5FileDialog from E5Gui.E5MainWindow import E5MainWindow @@ -142,12 +144,14 @@ self.__cancelButton.show() msg = self.tr( - "Plugin ZIP-Archives:\n{0}\n\nDestination:\n{1} ({2})")\ - .format("\n".join(self.__createArchivesList()), - self.destinationCombo.currentText(), - self.destinationCombo.itemData( - self.destinationCombo.currentIndex()) - ) + "Plugin ZIP-Archives:\n{0}\n\nDestination:\n{1} ({2})" + ).format( + "\n".join(self.__createArchivesList()), + self.destinationCombo.currentText(), + self.destinationCombo.itemData( + self.destinationCombo.currentIndex() + ) + ) self.summaryEdit.setPlainText(msg) @pyqtSlot() @@ -268,27 +272,33 @@ # check, if the archive exists if not os.path.exists(archive): - return False, \ + return ( + False, self.tr( """<p>The archive file <b>{0}</b> does not exist. """ - """Aborting...</p>""").format(archive), \ + """Aborting...</p>""").format(archive), False + ) # check, if the archive is a valid zip file if not zipfile.is_zipfile(archive): - return False, \ + return ( + False, self.tr( """<p>The file <b>{0}</b> is not a valid plugin """ - """ZIP-archive. Aborting...</p>""").format(archive), \ + """ZIP-archive. Aborting...</p>""").format(archive), False + ) # check, if the destination is writeable if not os.access(destination, os.W_OK): - return False, \ + return ( + False, self.tr( """<p>The destination directory <b>{0}</b> is not """ - """writeable. Aborting...</p>""").format(destination), \ + """writeable. Aborting...</p>""").format(destination), False + ) zipFile = zipfile.ZipFile(archive, "r") @@ -303,11 +313,13 @@ break if not pluginFound: - return False, \ + return ( + False, self.tr( """<p>The file <b>{0}</b> is not a valid plugin """ - """ZIP-archive. Aborting...</p>""").format(archive), \ + """ZIP-archive. Aborting...</p>""").format(archive), False + ) # parse the plugin module's plugin header pluginSource = Utilities.decode(zipFile.read(pluginFileName))[0] @@ -319,8 +331,10 @@ for line in pluginSource.splitlines(): if line.startswith("packageName"): tokens = line.split("=") - if tokens[0].strip() == "packageName" and \ - tokens[1].strip()[1:-1] != "__core__": + if ( + tokens[0].strip() == "packageName" and + tokens[1].strip()[1:-1] != "__core__" + ): if tokens[1].strip()[0] in ['"', "'"]: packageName = tokens[1].strip()[1:-1] else: @@ -348,54 +362,69 @@ break if not packageName: - return False, \ + return ( + False, self.tr( """<p>The plugin module <b>{0}</b> does not contain """ - """a 'packageName' attribute. Aborting...</p>""")\ - .format(pluginFileName), \ + """a 'packageName' attribute. Aborting...</p>""" + ).format(pluginFileName), False + ) if pyqtApi < 2: - return False, \ + return ( + False, self.tr( """<p>The plugin module <b>{0}</b> does not conform""" - """ with the PyQt v2 API. Aborting...</p>""")\ - .format(pluginFileName), \ + """ with the PyQt v2 API. Aborting...</p>""" + ).format(pluginFileName), False + ) # check, if it is a plugin, that collides with others - if not os.path.exists(os.path.join(destination, pluginFileName)) and \ - packageName != "None" and \ - os.path.exists(os.path.join(destination, packageName)): - return False, \ + if ( + not os.path.exists(os.path.join(destination, pluginFileName)) and + packageName != "None" and + os.path.exists(os.path.join(destination, packageName)) + ): + return ( + False, self.tr("""<p>The plugin package <b>{0}</b> exists. """ - """Aborting...</p>""")\ - .format(os.path.join(destination, packageName)), \ + """Aborting...</p>""").format( + os.path.join(destination, packageName)), False + ) - if os.path.exists(os.path.join(destination, pluginFileName)) and \ - packageName != "None" and \ - not os.path.exists(os.path.join(destination, packageName)): - return False, \ + if ( + os.path.exists(os.path.join(destination, pluginFileName)) and + packageName != "None" and + not os.path.exists(os.path.join(destination, packageName)) + ): + return ( + False, self.tr("""<p>The plugin module <b>{0}</b> exists. """ - """Aborting...</p>""")\ - .format(os.path.join(destination, pluginFileName)), \ + """Aborting...</p>""").format( + os.path.join(destination, pluginFileName)), False + ) activatePlugin = False if not self.__external: - activatePlugin = \ + activatePlugin = ( not self.__pluginManager.isPluginLoaded( - installedPluginName) or \ + installedPluginName) or (self.__pluginManager.isPluginLoaded(installedPluginName) and self.__pluginManager.isPluginActive(installedPluginName)) + ) # try to unload a plugin with the same name self.__pluginManager.unloadPlugin(installedPluginName) # uninstall existing plug-in first to get clean conditions - if packageName != "None" and \ + if ( + packageName != "None" and not os.path.exists( - os.path.join(destination, packageName, "__init__.py")): + os.path.join(destination, packageName, "__init__.py")) + ): # package directory contains just data, don't delete it self.__uninstallPackage(destination, pluginFileName, "") else: @@ -419,9 +448,11 @@ self.progress.setValue(prog) QApplication.processEvents() prog += 1 - if name == pluginFileName or \ - name.startswith("{0}/".format(packageName)) or \ - name.startswith("{0}\\".format(packageName)): + if ( + name == pluginFileName or + name.startswith("{0}/".format(packageName)) or + name.startswith("{0}\\".format(packageName)) + ): outname = name.replace("/", os.sep) outname = os.path.join(destination, outname) if outname.endswith("/") or outname.endswith("\\"): @@ -449,28 +480,36 @@ self.__installedFiles.append(outname) except os.error as why: self.__rollback() - return False, \ + return ( + False, self.tr( - "Error installing plugin. Reason: {0}").format(str(why)), \ + "Error installing plugin. Reason: {0}").format(str(why)), False + ) except IOError as why: self.__rollback() - return False, \ + return ( + False, self.tr( - "Error installing plugin. Reason: {0}").format(str(why)), \ + "Error installing plugin. Reason: {0}").format(str(why)), False + ) except OSError as why: self.__rollback() - return False, \ + return ( + False, self.tr( - "Error installing plugin. Reason: {0}").format(str(why)), \ + "Error installing plugin. Reason: {0}").format(str(why)), False + ) except Exception: sys.stderr.write("Unspecific exception installing plugin.\n") self.__rollback() - return False, \ - self.tr("Unspecific exception installing plugin."), \ + return ( + False, + self.tr("Unspecific exception installing plugin."), False + ) # now compile the plugins if doCompile: