eric6/PluginManager/PluginManager.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7967
f5da85158db2
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7900
diff changeset
3 # Copyright (c) 2007 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Plugin Manager.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import sys
3112
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
12 import zipfile
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
13 import types
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
14 import importlib
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 from PyQt5.QtCore import (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
17 pyqtSignal, QObject, QDate, QFile, QFileInfo, QUrl, QIODevice
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
18 )
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
19 from PyQt5.QtGui import QPixmap
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
20 from PyQt5.QtNetwork import (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
21 QNetworkAccessManager, QNetworkRequest, QNetworkReply
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
22 )
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 496
diff changeset
23
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 496
diff changeset
24 from E5Gui import E5MessageBox
4113
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
25 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
3112
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
27 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
28 try:
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
29 from E5Network.E5SslErrorHandler import E5SslErrorHandler
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
30 SSL_AVAILABLE = True
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
31 except ImportError:
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
32 SSL_AVAILABLE = False
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
33
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
34 from .PluginExceptions import (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
35 PluginPathError, PluginModulesError, PluginLoadError,
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
36 PluginActivationError, PluginModuleFormatError, PluginClassFormatError
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
37 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
6605
6ae78749babc PluginManager: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6360
diff changeset
41 import Globals
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 import Utilities
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
45 from eric6config import getConfig
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
47
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 class PluginManager(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Class implementing the Plugin Manager.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @signal shutdown() emitted at shutdown of the IDE
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
53 @signal pluginAboutToBeActivated(modulName, pluginObject) emitted just
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
54 before a plugin is activated
3259
f059575254df Fixed some typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3200
diff changeset
55 @signal pluginActivated(moduleName, pluginObject) emitted just after
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
56 a plugin was activated
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @signal allPlugginsActivated() emitted at startup after all plugins have
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 been activated
3259
f059575254df Fixed some typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3200
diff changeset
59 @signal pluginAboutToBeDeactivated(moduleName, pluginObject) emitted just
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
60 before a plugin is deactivated
3259
f059575254df Fixed some typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3200
diff changeset
61 @signal pluginDeactivated(moduleName, pluginObject) emitted just after
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
62 a plugin was deactivated
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
64 shutdown = pyqtSignal()
496
ed1e3f654d0b Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
65 pluginAboutToBeActivated = pyqtSignal(str, object)
ed1e3f654d0b Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
66 pluginActivated = pyqtSignal(str, object)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
67 allPlugginsActivated = pyqtSignal()
496
ed1e3f654d0b Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
68 pluginAboutToBeDeactivated = pyqtSignal(str, object)
ed1e3f654d0b Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
69 pluginDeactivated = pyqtSignal(str, object)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
70
6267
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
71 def __init__(self, parent=None, disabledPlugins=None, doLoadPlugins=True,
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
72 develPlugin=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 The Plugin Manager deals with three different plugin directories.
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
77 The first is the one, that is part of eric6 (eric6/Plugins). The
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
78 second one is the global plugin directory called 'eric6plugins',
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 which is located inside the site-packages directory. The last one
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
80 is the user plugin directory located inside the .eric6 directory
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 of the users home directory.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
6267
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
83 @param parent reference to the parent object
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
84 @type QObject
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
85 @param disabledPlugins list of plug-ins that have been disabled via
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
86 the command line parameters '--disable-plugin='
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
87 @type list of str
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
88 @param doLoadPlugins flag indicating, that plug-ins should
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
89 be loaded
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
90 @type bool
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
91 @param develPlugin filename of a plug-in to be loaded for
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
92 development
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
93 @type str
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
94 @exception PluginPathError raised to indicate an invalid plug-in path
5726
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
95 @exception PluginModulesError raised to indicate the absence of
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
96 plug-in modules
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
98 super(PluginManager, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.__ui = parent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__develPluginFile = develPlugin
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__develPluginName = None
6267
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
103 if disabledPlugins is not None:
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
104 self.__disabledPlugins = disabledPlugins[:]
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
105 else:
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
106 self.__disabledPlugins = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.__inactivePluginsKey = "PluginManager/InactivePlugins"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.pluginDirs = {
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
111 "eric6": os.path.join(getConfig('ericDir'), "Plugins"),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
112 "global": os.path.join(Utilities.getPythonModulesDirectory(),
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
113 "eric6plugins"),
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
114 "user": os.path.join(Utilities.getConfigDir(), "eric6plugins"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 }
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
116 self.__priorityOrder = ["eric6", "global", "user"]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
118 self.__defaultDownloadDir = os.path.join(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
119 Utilities.getConfigDir(), "Downloads")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.__activePlugins = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 self.__inactivePlugins = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__onDemandActivePlugins = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.__onDemandInactivePlugins = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.__activeModules = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.__inactiveModules = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.__onDemandActiveModules = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.__onDemandInactiveModules = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.__failedModules = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.__foundCoreModules = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.__foundGlobalModules = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.__foundUserModules = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.__modulesCount = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 pdirsExist, msg = self.__pluginDirectoriesExist()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 if not pdirsExist:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 raise PluginPathError(msg)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 if doLoadPlugins:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 if not self.__pluginModulesExist():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 raise PluginModulesError
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.__insertPluginsPaths()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.__loadPlugins()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__checkPluginsDownloadDirectory()
3112
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
150
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
151 self.pluginRepositoryFile = os.path.join(Utilities.getConfigDir(),
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
152 "PluginRepository")
3112
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
153
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
154 # attributes for the network objects
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
155 self.__networkManager = QNetworkAccessManager(self)
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
156 self.__networkManager.proxyAuthenticationRequired.connect(
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
157 proxyAuthenticationRequired)
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
158 if SSL_AVAILABLE:
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
159 self.__sslErrorHandler = E5SslErrorHandler(self)
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
160 self.__networkManager.sslErrors.connect(self.__sslErrors)
9485059ea9fa Started implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3036
diff changeset
161 self.__replies = []
4630
7b0e38956b5c Refined the online state change behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4629
diff changeset
162
4798
ee1a24311b03 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
163 try:
ee1a24311b03 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
164 self.__ui.onlineStateChanged.connect(self.__onlineStateChanged)
ee1a24311b03 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
165 except AttributeError:
ee1a24311b03 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
166 # it was not called from eric
ee1a24311b03 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
167 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 def finalizeSetup(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 Public method to finalize the setup of the plugin manager.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 """
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
173 for module in (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
174 list(self.__onDemandInactiveModules.values()) +
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
175 list(self.__onDemandActiveModules.values())
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
176 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 if hasattr(module, "moduleSetup"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 module.moduleSetup()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 def getPluginDir(self, key):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 Public method to get the path of a plugin directory.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
184 @param key key of the plug-in directory (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 @return path of the requested plugin directory (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 if key not in ["global", "user"]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 return self.pluginDirs[key]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 def __pluginDirectoriesExist(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 Private method to check, if the plugin folders exist.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 If the plugin folders don't exist, they are created (if possible).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
201 @return tuple of a flag indicating existence of any of the plugin
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 directories (boolean) and a message (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 if self.__develPluginFile:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 path = Utilities.splitPath(self.__develPluginFile)[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 fname = os.path.join(path, "__init__.py")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 if not os.path.exists(fname):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 try:
7785
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7400
diff changeset
209 with open(fname, "w"):
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7400
diff changeset
210 pass
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
211 except OSError:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
212 return (
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
213 False,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3171
diff changeset
214 self.tr("Could not create a package for {0}.")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 .format(self.__develPluginFile))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
4378
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
217 fname = os.path.join(self.pluginDirs["user"], "__init__.py")
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
218 if not os.path.exists(fname):
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
219 if not os.path.exists(self.pluginDirs["user"]):
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
220 os.mkdir(self.pluginDirs["user"], 0o755)
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
221 try:
7785
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7400
diff changeset
222 with open(fname, "w"):
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7400
diff changeset
223 pass
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
224 except OSError:
4378
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
225 del self.pluginDirs["user"]
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
226
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
227 if not os.path.exists(self.pluginDirs["global"]):
7967
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
228 try:
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
229 # create the global plugins directory
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
230 os.mkdir(self.pluginDirs["global"], 0o755)
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
231 fname = os.path.join(self.pluginDirs["global"], "__init__.py")
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
232 with open(fname, "w", encoding="utf-8") as f:
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
233 f.write('# -*- coding: utf-8 -*-' + "\n")
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
234 f.write("\n")
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
235 f.write('"""' + "\n")
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
236 f.write('Package containing the global plugins.' + "\n")
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
237 f.write('"""' + "\n")
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
238 except OSError:
f5da85158db2 PluginManager: changed the code to create a global plugins directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7946
diff changeset
239 del self.pluginDirs["global"]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
241 if not os.path.exists(self.pluginDirs["eric6"]):
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
242 return (
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
243 False,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3171
diff changeset
244 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
245 "The internal plugin directory <b>{0}</b>"
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
246 " does not exits.").format(self.pluginDirs["eric6"]))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 return (True, "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 def __pluginModulesExist(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 Private method to check, if there are plugins available.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 @return flag indicating the availability of plugins (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 """
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
256 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
257 self.__develPluginFile and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
258 not os.path.exists(self.__develPluginFile)
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
259 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
262 self.__foundCoreModules = self.getPluginModules(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
263 self.pluginDirs["eric6"])
4378
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
264 if Preferences.getPluginManager("ActivateExternal"):
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
265 if "global" in self.pluginDirs:
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
266 self.__foundGlobalModules = self.getPluginModules(
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
267 self.pluginDirs["global"])
4378
d8f81e864816 Changed the 'load external plug-ins' logic and enable this option upon installation of a plug-in, if it is switched off (needs a restart of eric).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4115
diff changeset
268 if "user" in self.pluginDirs:
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
269 self.__foundUserModules = self.getPluginModules(
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
270 self.pluginDirs["user"])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
272 return len(self.__foundCoreModules + self.__foundGlobalModules +
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 self.__foundUserModules) > 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 def getPluginModules(self, pluginPath):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 Public method to get a list of plugin modules.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 @param pluginPath name of the path to search (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 @return list of plugin module names (list of string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
282 pluginFiles = [f[:-3] for f in os.listdir(pluginPath)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 if self.isValidPluginName(f)]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 return pluginFiles[:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 def isValidPluginName(self, pluginName):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 Public methode to check, if a file name is a valid plugin name.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 Plugin modules must start with "Plugin" and have the extension ".py".
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 @param pluginName name of the file to be checked (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 @return flag indicating a valid plugin name (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 return pluginName.startswith("Plugin") and pluginName.endswith(".py")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 def __insertPluginsPaths(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 Private method to insert the valid plugin paths intos the search path.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 for key in self.__priorityOrder:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 if key in self.pluginDirs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 if not self.pluginDirs[key] in sys.path:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 sys.path.insert(2, self.pluginDirs[key])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 UI.PixmapCache.addSearchPath(self.pluginDirs[key])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 if self.__develPluginFile:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 path = Utilities.splitPath(self.__develPluginFile)[0]
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
309 if path not in sys.path:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 sys.path.insert(2, path)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 UI.PixmapCache.addSearchPath(path)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 def __loadPlugins(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 Private method to load the plugins found.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 develPluginName = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 if self.__develPluginFile:
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
319 develPluginPath, develPluginName = Utilities.splitPath(
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
320 self.__develPluginFile)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 if self.isValidPluginName(develPluginName):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 develPluginName = develPluginName[:-3]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 for pluginName in self.__foundGlobalModules:
6008
ac5057f80f60 Changed the order of precedence for loading plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5904
diff changeset
325 # user and core plug-ins have priority
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
326 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
327 pluginName not in self.__foundUserModules and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
328 pluginName not in self.__foundCoreModules and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
329 pluginName != develPluginName
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
330 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 self.loadPlugin(pluginName, self.pluginDirs["global"])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 for pluginName in self.__foundUserModules:
6008
ac5057f80f60 Changed the order of precedence for loading plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5904
diff changeset
334 # core plug-ins have priority
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
335 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
336 pluginName not in self.__foundCoreModules and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
337 pluginName != develPluginName
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
338 ):
6008
ac5057f80f60 Changed the order of precedence for loading plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5904
diff changeset
339 self.loadPlugin(pluginName, self.pluginDirs["user"])
ac5057f80f60 Changed the order of precedence for loading plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5904
diff changeset
340
ac5057f80f60 Changed the order of precedence for loading plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5904
diff changeset
341 for pluginName in self.__foundCoreModules:
ac5057f80f60 Changed the order of precedence for loading plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5904
diff changeset
342 # plug-in under development has priority
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 if pluginName != develPluginName:
6008
ac5057f80f60 Changed the order of precedence for loading plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5904
diff changeset
344 self.loadPlugin(pluginName, self.pluginDirs["eric6"])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 if develPluginName:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 self.loadPlugin(develPluginName, develPluginPath)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 self.__develPluginName = develPluginName
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349
6629
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
350 def loadDocumentationSetPlugins(self):
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
351 """
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
352 Public method to load just the documentation sets plugins.
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
353
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
354 @exception PluginModulesError raised to indicate the absence of
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
355 plug-in modules
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
356 """
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
357 if not self.__pluginModulesExist():
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
358 raise PluginModulesError
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
359
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
360 self.__insertPluginsPaths()
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
361
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
362 for pluginName in self.__foundGlobalModules:
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
363 # user and core plug-ins have priority
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
364 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
365 pluginName not in self.__foundUserModules and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
366 pluginName not in self.__foundCoreModules and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
367 pluginName.startswith("PluginDocumentationSets")
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
368 ):
6629
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
369 self.loadPlugin(pluginName, self.pluginDirs["global"])
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
370
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
371 for pluginName in self.__foundUserModules:
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
372 # core plug-ins have priority
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
373 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
374 pluginName not in self.__foundCoreModules and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
375 pluginName.startswith("PluginDocumentationSets")
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
376 ):
6629
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
377 self.loadPlugin(pluginName, self.pluginDirs["user"])
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
378
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
379 for pluginName in self.__foundCoreModules:
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
380 # plug-in under development has priority
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
381 if pluginName.startswith("PluginDocumentationSets"):
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
382 self.loadPlugin(pluginName, self.pluginDirs["eric6"])
643ec3a53d17 PluginManager, QtHelpDocumentationDialog: fixed loading plug-in documentation sets when run stand-alone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6611
diff changeset
383
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
384 def loadPlugin(self, name, directory, reload_=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 Public method to load a plugin module.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 Initially all modules are inactive. Modules that are requested on
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 demand are sorted out and are added to the on demand list. Some
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 basic validity checks are performed as well. Modules failing these
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 checks are added to the failed modules list.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 @param name name of the module to be loaded (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 @param directory name of the plugin directory (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 @param reload_ flag indicating to reload the module (boolean)
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
396 @exception PluginLoadError raised to indicate an issue loading
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
397 the plug-in
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 try:
415
59a0f9e90768 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
400 fname = "{0}.py".format(os.path.join(directory, name))
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
401 spec = importlib.util.spec_from_file_location(name, fname)
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
402 module = importlib.util.module_from_spec(spec)
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
403 sys.modules[module.__name__] = module
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
404 spec.loader.exec_module(module)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 if not hasattr(module, "autoactivate"):
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3171
diff changeset
406 module.error = self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
407 "Module is missing the 'autoactivate' attribute.")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 self.__failedModules[name] = module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 raise PluginLoadError(name)
7023
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
410 if getattr(module, "autoactivate", False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 self.__inactiveModules[name] = module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 else:
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
413 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
414 not hasattr(module, "pluginType") or
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
415 not hasattr(module, "pluginTypename")
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
416 ):
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
417 module.error = self.tr(
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
418 "Module is missing the 'pluginType' "
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
419 "and/or 'pluginTypename' attributes."
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
420 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.__failedModules[name] = module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 raise PluginLoadError(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 self.__onDemandInactiveModules[name] = module
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
425 module.eric6PluginModuleName = name
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
426 module.eric6PluginModuleFilename = fname
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 self.__modulesCount += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 if reload_:
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
429 importlib.reload(module)
4115
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
430 self.initOnDemandPlugin(name)
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
431 try:
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
432 pluginObject = self.__onDemandInactivePlugins[name]
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
433 pluginObject.initToolbar(
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
434 self.__ui, e5App().getObject("ToolbarManager"))
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
435 except (KeyError, AttributeError):
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
436 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 except PluginLoadError:
3520
bfcefbb1633c Implemented the Python2 compatibility check for plug-ins in the plug-in manager. The flag is named 'python2Compatible'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
438 print("Error loading plug-in module:", name)
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
439 except Exception as err:
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
440 module = types.ModuleType(name)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3171
diff changeset
441 module.error = self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
442 "Module failed to load. Error: {0}").format(str(err))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 self.__failedModules[name] = module
3520
bfcefbb1633c Implemented the Python2 compatibility check for plug-ins in the plug-in manager. The flag is named 'python2Compatible'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
444 print("Error loading plug-in module:", name)
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
445 print(str(err))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446
2889
3737e9f17f44 Fixed an issue in the plug-in manager causing a traceback when installing a new plug-in version of an already loaded one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
447 def unloadPlugin(self, name):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 Public method to unload a plugin module.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 @param name name of the module to be unloaded (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 @return flag indicating success (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 """
2889
3737e9f17f44 Fixed an issue in the plug-in manager causing a traceback when installing a new plug-in version of an already loaded one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
454 if name in self.__onDemandActiveModules:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 # cannot unload an ondemand plugin, that is in use
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457
2889
3737e9f17f44 Fixed an issue in the plug-in manager causing a traceback when installing a new plug-in version of an already loaded one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
458 if name in self.__activeModules:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 self.deactivatePlugin(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460
2889
3737e9f17f44 Fixed an issue in the plug-in manager causing a traceback when installing a new plug-in version of an already loaded one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
461 if name in self.__inactiveModules:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 try:
4115
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
463 pluginObject = self.__inactivePlugins[name]
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
464 try:
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
465 pluginObject.prepareUnload()
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
466 except AttributeError:
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
467 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 del self.__inactivePlugins[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 del self.__inactiveModules[name]
2889
3737e9f17f44 Fixed an issue in the plug-in manager causing a traceback when installing a new plug-in version of an already loaded one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
472 elif name in self.__onDemandInactiveModules:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 try:
4115
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
474 pluginObject = self.__onDemandInactivePlugins[name]
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
475 try:
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
476 pluginObject.prepareUnload()
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
477 except AttributeError:
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
478 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 del self.__onDemandInactivePlugins[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 del self.__onDemandInactiveModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 elif name in self.__failedModules:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 del self.__failedModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 self.__modulesCount -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
489 def removePluginFromSysModules(self, pluginName, package,
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
490 internalPackages):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
492 Public method to remove a plugin and all related modules from
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
493 sys.modules.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 @param pluginName name of the plugin module (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 @param package name of the plugin package (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 @param internalPackages list of intenal packages (list of string)
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
498 @return flag indicating the plugin module was found in sys.modules
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
499 (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 packages = [package] + internalPackages
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 found = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 if not package:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 package = "__None__"
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
505 for moduleName in list(sys.modules.keys())[:]:
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
506 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
507 moduleName == pluginName or
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
508 moduleName.split(".")[0] in packages
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
509 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 found = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 del sys.modules[moduleName]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 return found
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 def initOnDemandPlugins(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 Public method to create plugin objects for all on demand plugins.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 Note: The plugins are not activated.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 names = sorted(self.__onDemandInactiveModules.keys())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 for name in names:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 self.initOnDemandPlugin(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 def initOnDemandPlugin(self, name):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 Public method to create a plugin object for the named on demand plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
528 Note: The plug-in is not activated.
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
529
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
530 @param name name of the plug-in (string)
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
531 @exception PluginActivationError raised to indicate an issue during the
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
532 plug-in activation
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 module = self.__onDemandInactiveModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 except KeyError:
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
538 return
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 if not self.__canActivatePlugin(module):
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
541 raise PluginActivationError(module.eric6PluginModuleName)
7023
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
542 version = getattr(module, "version", "0.0.0")
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
543 className = getattr(module, "className", "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 pluginClass = getattr(module, className)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 pluginObject = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 if name not in self.__onDemandInactivePlugins:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 pluginObject = pluginClass(self.__ui)
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
548 pluginObject.eric6PluginModule = module
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
549 pluginObject.eric6PluginName = className
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
550 pluginObject.eric6PluginVersion = version
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 self.__onDemandInactivePlugins[name] = pluginObject
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 except PluginActivationError:
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
553 return
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554
4113
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
555 def initPluginToolbars(self, toolbarManager):
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
556 """
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
557 Public method to initialize plug-in toolbars.
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
558
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
559 @param toolbarManager reference to the toolbar manager object
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
560 (E5ToolBarManager)
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
561 """
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
562 self.initOnDemandPlugins()
4115
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
563 for pluginObject in self.__onDemandInactivePlugins.values():
4113
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
564 try:
4115
0c70a8f8d54a Some more modifications to improve the plug-in toolbar handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4113
diff changeset
565 pluginObject.initToolbar(self.__ui, toolbarManager)
4113
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
566 except AttributeError:
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
567 # ignore it
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
568 pass
feac3108a780 Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
569
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 def activatePlugins(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
572 Public method to activate all plugins having the "autoactivate"
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
573 attribute set to True.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
575 savedInactiveList = Preferences.Prefs.settings.value(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
576 self.__inactivePluginsKey)
6267
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
577 inactiveList = self.__disabledPlugins[:]
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
578 if savedInactiveList is not None:
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
579 inactiveList += [p for p in savedInactiveList
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
580 if p not in self.__disabledPlugins]
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
581 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
582 self.__develPluginName is not None and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
583 self.__develPluginName in inactiveList
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
584 ):
6267
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
585 inactiveList.remove(self.__develPluginName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 names = sorted(self.__inactiveModules.keys())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 for name in names:
6267
350655a6c85f eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
588 if name not in inactiveList:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 self.activatePlugin(name)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
590 self.allPlugginsActivated.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
592 def activatePlugin(self, name, onDemand=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 Public method to activate a plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 @param name name of the module to be activated
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
597 @param onDemand flag indicating activation of an
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 on demand plugin (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 @return reference to the initialized plugin object
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
600 @exception PluginActivationError raised to indicate an issue during the
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
601 plug-in activation
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 if onDemand:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 module = self.__onDemandInactiveModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 module = self.__inactiveModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 if not self.__canActivatePlugin(module):
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
613 raise PluginActivationError(module.eric6PluginModuleName)
7023
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
614 version = getattr(module, "version", "0.0.0")
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
615 className = getattr(module, "className", "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616 pluginClass = getattr(module, className)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 pluginObject = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 if onDemand and name in self.__onDemandInactivePlugins:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 pluginObject = self.__onDemandInactivePlugins[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 elif not onDemand and name in self.__inactivePlugins:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 pluginObject = self.__inactivePlugins[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 pluginObject = pluginClass(self.__ui)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
624 self.pluginAboutToBeActivated.emit(name, pluginObject)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 obj, ok = pluginObject.activate()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 except TypeError:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3171
diff changeset
628 module.error = self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
629 "Incompatible plugin activation method.")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 obj = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 ok = True
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
632 except Exception as err:
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
633 module.error = str(err)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 obj = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 if not ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
639 self.pluginActivated.emit(name, pluginObject)
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
640 pluginObject.eric6PluginModule = module
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
641 pluginObject.eric6PluginName = className
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
642 pluginObject.eric6PluginVersion = version
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 if onDemand:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 self.__onDemandInactiveModules.pop(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 self.__onDemandInactivePlugins.pop(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 self.__onDemandActivePlugins[name] = pluginObject
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 self.__onDemandActiveModules[name] = module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 self.__inactiveModules.pop(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 self.__inactivePlugins.pop(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 self.__activePlugins[name] = pluginObject
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 self.__activeModules[name] = module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 return obj
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 except PluginActivationError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 def __canActivatePlugin(self, module):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 Private method to check, if a plugin can be activated.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 @param module reference to the module to be activated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 @return flag indicating, if the module satisfies all requirements
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 for being activated (boolean)
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
671 @exception PluginModuleFormatError raised to indicate an invalid
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
672 plug-in module format
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
673 @exception PluginClassFormatError raised to indicate an invalid
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2889
diff changeset
674 plug-in class format
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 if not hasattr(module, "version"):
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
678 raise PluginModuleFormatError(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
679 module.eric6PluginModuleName, "version")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 if not hasattr(module, "className"):
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
681 raise PluginModuleFormatError(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
682 module.eric6PluginModuleName, "className")
7023
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
683 className = getattr(module, "className", "")
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
684 if not className or not hasattr(module, className):
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
685 raise PluginModuleFormatError(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
686 module.eric6PluginModuleName, className)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687 pluginClass = getattr(module, className)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688 if not hasattr(pluginClass, "__init__"):
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
689 raise PluginClassFormatError(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
690 module.eric6PluginModuleName,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
691 className, "__init__")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 if not hasattr(pluginClass, "activate"):
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
693 raise PluginClassFormatError(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
694 module.eric6PluginModuleName,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 className, "activate")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 if not hasattr(pluginClass, "deactivate"):
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
697 raise PluginClassFormatError(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
698 module.eric6PluginModuleName,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699 className, "deactivate")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 return True
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
701 except PluginModuleFormatError as e:
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
702 print(repr(e))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 return False
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
704 except PluginClassFormatError as e:
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
705 print(repr(e))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
708 def deactivatePlugin(self, name, onDemand=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 Public method to deactivate a plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712 @param name name of the module to be deactivated
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
713 @param onDemand flag indicating deactivation of an
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 on demand plugin (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 if onDemand:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 module = self.__onDemandActiveModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 module = self.__activeModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 if self.__canDeactivatePlugin(module):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 pluginObject = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 if onDemand and name in self.__onDemandActivePlugins:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 pluginObject = self.__onDemandActivePlugins[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 elif not onDemand and name in self.__activePlugins:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 pluginObject = self.__activePlugins[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 if pluginObject:
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
731 self.pluginAboutToBeDeactivated.emit(name, pluginObject)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 pluginObject.deactivate()
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
733 self.pluginDeactivated.emit(name, pluginObject)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 if onDemand:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 self.__onDemandActiveModules.pop(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737 self.__onDemandActivePlugins.pop(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 self.__onDemandInactivePlugins[name] = pluginObject
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 self.__onDemandInactiveModules[name] = module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 self.__activeModules.pop(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743 self.__activePlugins.pop(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 self.__inactivePlugins[name] = pluginObject
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 self.__inactiveModules[name] = module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 def __canDeactivatePlugin(self, module):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 Private method to check, if a plugin can be deactivated.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 @param module reference to the module to be deactivated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 @return flag indicating, if the module satisfies all requirements
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 for being deactivated (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 return getattr(module, "deactivateable", True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
759 def getPluginObject(self, type_, typename, maybeActive=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
761 Public method to activate an ondemand plugin given by type and
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
762 typename.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 @param type_ type of the plugin to be activated (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 @param typename name of the plugin within the type category (string)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
766 @param maybeActive flag indicating, that the plugin may be active
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 already (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 @return reference to the initialized plugin object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
770 for name, module in list(self.__onDemandInactiveModules.items()):
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
771 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
772 getattr(module, "pluginType", "") == type_ and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
773 getattr(module, "pluginTypename", "") == typename
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
774 ):
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
775 return self.activatePlugin(name, onDemand=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 if maybeActive:
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
778 for name, module in list(self.__onDemandActiveModules.items()):
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
779 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
780 getattr(module, "pluginType", "") == type_ and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
781 getattr(module, "pluginTypename", "") == typename
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
782 ):
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
783 self.deactivatePlugin(name, onDemand=True)
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
784 return self.activatePlugin(name, onDemand=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 def getPluginInfos(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 """
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
790 Public method to get infos about all loaded plug-ins.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
792 @return list of dictionaries with keys "module_name", "plugin_name",
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
793 "version", "auto_activate", "active", "short_desc", "error"
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
794 @rtype list of dict ("module_name": str, "plugin_name": str,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
795 "version": str, "auto_activate": bool, "active": bool,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
796 "short_desc": str, "error": bool)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 infos = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
800 # 1. active, non-on-demand modules
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
801 for name in list(self.__activeModules.keys()):
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
802 info = self.__getShortInfo(self.__activeModules[name])
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
803 info.update({
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
804 "module_name": name,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
805 "auto_activate": True,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
806 "active": True,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
807 })
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
808 infos.append(info)
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
809
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
810 # 2. inactive, non-on-demand modules
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
811 for name in list(self.__inactiveModules.keys()):
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
812 info = self.__getShortInfo(self.__inactiveModules[name])
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
813 info.update({
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
814 "module_name": name,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
815 "auto_activate": True,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
816 "active": False,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
817 })
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
818 infos.append(info)
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
819
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
820 # 3. active, on-demand modules
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
821 for name in list(self.__onDemandActiveModules.keys()):
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
822 info = self.__getShortInfo(self.__onDemandActiveModules[name])
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
823 info.update({
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
824 "module_name": name,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
825 "auto_activate": False,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
826 "active": True,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
827 })
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
828 infos.append(info)
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
829
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
830 # 4. inactive, non-on-demand modules
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
831 for name in list(self.__onDemandInactiveModules.keys()):
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
832 info = self.__getShortInfo(self.__onDemandInactiveModules[name])
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
833 info.update({
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
834 "module_name": name,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
835 "auto_activate": False,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
836 "active": False,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
837 })
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
838 infos.append(info)
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
839
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
840 # 5. failed modules
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
841 for name in list(self.__failedModules.keys()):
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
842 info = self.__getShortInfo(self.__failedModules[name])
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
843 info.update({
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
844 "module_name": name,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
845 "auto_activate": False,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
846 "active": False,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
847 })
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
848 infos.append(info)
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
849
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850 return infos
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 def __getShortInfo(self, module):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 Private method to extract the short info from a module.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 @param module module to extract short info from
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
857 @return dictionay containing plug-in data
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
858 @rtype dict ("plugin_name": str, "version": str, "short_desc": str,
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
859 "error": bool)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 """
6080
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
861 return {
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
862 "plugin_name": getattr(module, "name", ""),
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
863 "version": getattr(module, "version", ""),
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
864 "short_desc": getattr(module, "shortDescription", ""),
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
865 "error": bool(getattr(module, "error", "")),
436ac20f7639 Made the output of the plug-ins info dialog a bit more understandable and refactored related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
866 }
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 def getPluginDetails(self, name):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 Public method to get detailed information about a plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 @param name name of the module to get detailed infos about (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873 @return details of the plugin as a dictionary
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 details = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 autoactivate = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 active = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 if name in self.__activeModules:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 module = self.__activeModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 elif name in self.__inactiveModules:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 module = self.__inactiveModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 active = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 elif name in self.__onDemandActiveModules:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886 module = self.__onDemandActiveModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 autoactivate = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 elif name in self.__onDemandInactiveModules:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
889 module = self.__onDemandInactiveModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
890 autoactivate = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 active = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892 elif name in self.__failedModules:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893 module = self.__failedModules[name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
894 autoactivate = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 active = False
5236
9487d3fbb71e Change to the plug-in manager to support plug-in sets (like the documentation sets plug-ins). These containe a '_' in the plug-in archive name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5223
diff changeset
896 elif "_" in name:
9487d3fbb71e Change to the plug-in manager to support plug-in sets (like the documentation sets plug-ins). These containe a '_' in the plug-in archive name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5223
diff changeset
897 # try stripping of a postfix
9487d3fbb71e Change to the plug-in manager to support plug-in sets (like the documentation sets plug-ins). These containe a '_' in the plug-in archive name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5223
diff changeset
898 return self.getPluginDetails(name.rsplit("_", 1)[0])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
899 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 # should not happen
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
903 details["moduleName"] = name
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
904 details["moduleFileName"] = getattr(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
905 module, "eric6PluginModuleFilename", "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
906 details["pluginName"] = getattr(module, "name", "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907 details["version"] = getattr(module, "version", "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
908 details["author"] = getattr(module, "author", "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
909 details["description"] = getattr(module, "longDescription", "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
910 details["autoactivate"] = autoactivate
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 details["active"] = active
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 details["error"] = getattr(module, "error", "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 return details
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915
496
ed1e3f654d0b Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
916 def doShutdown(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
917 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
918 Public method called to perform actions upon shutdown of the IDE.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 names = []
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
921 for name in list(self.__inactiveModules.keys()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 names.append(name)
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
923 Preferences.Prefs.settings.setValue(self.__inactivePluginsKey, names)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 438
diff changeset
925 self.shutdown.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 def getPluginDisplayStrings(self, type_):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
929 Public method to get the display strings of all plugins of a specific
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
930 type.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 @param type_ type of the plugins (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
933 @return dictionary with name as key and display string as value
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 (dictionary of string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936 pluginDict = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
938 for module in (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
939 list(self.__onDemandActiveModules.values()) +
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
940 list(self.__onDemandInactiveModules.values())
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
941 ):
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
942 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
943 getattr(module, "pluginType", "") == type_ and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
944 getattr(module, "error", "") == ""
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
945 ):
7023
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
946 plugin_name = getattr(module, "pluginTypename", "")
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
947 if plugin_name:
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
948 if hasattr(module, "displayString"):
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
949 try:
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
950 disp = module.displayString()
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
951 except TypeError:
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
952 disp = getattr(module, "displayString", "")
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
953 if disp != "":
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
954 pluginDict[plugin_name] = disp
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
955 else:
b025e93cc27d PluginManager, PluginUninstallDialog: changed some getattr() calls detected by the new code style checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
956 pluginDict[plugin_name] = plugin_name
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 return pluginDict
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 def getPluginPreviewPixmap(self, type_, name):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 Public method to get a preview pixmap of a plugin of a specific type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 @param type_ type of the plugin (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 @param name name of the plugin type (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 @return preview pixmap (QPixmap)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 """
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
968 for module in (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
969 list(self.__onDemandActiveModules.values()) +
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
970 list(self.__onDemandInactiveModules.values())
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
971 ):
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
972 if (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
973 getattr(module, "pluginType", "") == type_ and
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
974 getattr(module, "pluginTypename", "") == name
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
975 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 if hasattr(module, "previewPix"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 return module.previewPix()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 return QPixmap()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 return QPixmap()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 def getPluginApiFiles(self, language):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
985 Public method to get the list of API files installed by a plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 @param language language of the requested API files (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 @return list of API filenames (list of string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
990 apis = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
992 for module in (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
993 list(self.__activeModules.values()) +
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
994 list(self.__onDemandActiveModules.values())
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
995 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 if hasattr(module, "apiFiles"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997 apis.extend(module.apiFiles(language))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 return apis
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000
5223
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1001 def getPluginQtHelpFiles(self):
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1002 """
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1003 Public method to get the list of QtHelp documentation files provided
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1004 by a plug-in.
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1005
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1006 @return dictionary with documentation type as key and list of files
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1007 as value
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1008 @rtype dict (key: str, value: list of str)
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1009 """
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1010 helpFiles = {}
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1011 for module in (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1012 list(self.__activeModules.values()) +
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1013 list(self.__onDemandActiveModules.values())
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1014 ):
5223
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1015 if hasattr(module, "helpFiles"):
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1016 helpFiles.update(module.helpFiles())
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1017
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1018 return helpFiles
4c0b3ee7d2d8 Prepared the plug-in manager for a new plug-in type (providing documentation as QtHelp files (*.qch)).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4798
diff changeset
1019
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 def getPluginExeDisplayData(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 Public method to get data to display information about a plugins
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 external tool.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 @return list of dictionaries containing the data. Each dictionary must
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1026 either contain data for the determination or the data to be
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1027 displayed.<br />
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 A dictionary of the first form must have the following entries:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 <ul>
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1030 <li>programEntry - indicator for this dictionary form
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1031 (boolean), always True</li>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1032 <li>header - string to be diplayed as a header (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033 <li>exe - the executable (string)</li>
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1034 <li>versionCommand - commandline parameter for the exe
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1035 (string)</li>
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1036 <li>versionStartsWith - indicator for the output line
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1037 containing the version (string)</li>
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1038 <li>versionPosition - number of element containing the
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039 version (integer)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040 <li>version - version to be used as default (string)</li>
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1041 <li>versionCleanup - tuple of two integers giving string
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1042 positions start and stop for the version string
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1043 (tuple of integers)</li>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044 </ul>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 A dictionary of the second form must have the following entries:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 <ul>
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1047 <li>programEntry - indicator for this dictionary form
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1048 (boolean), always False</li>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1049 <li>header - string to be diplayed as a header (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 <li>text - entry text to be shown (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 <li>version - version text to be shown (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1052 </ul>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1053 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1054 infos = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1055
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1056 for module in (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1057 list(self.__activeModules.values()) +
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1058 list(self.__inactiveModules.values())
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1059 ):
438
f62a3f9d2e28 Changed code to include Qt Help tools in programs detection and introduced the 'exeDisplayDataList' plug-in function to report back a list of tools to check for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 415
diff changeset
1060 if hasattr(module, "exeDisplayDataList"):
f62a3f9d2e28 Changed code to include Qt Help tools in programs detection and introduced the 'exeDisplayDataList' plug-in function to report back a list of tools to check for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 415
diff changeset
1061 infos.extend(module.exeDisplayDataList())
f62a3f9d2e28 Changed code to include Qt Help tools in programs detection and introduced the 'exeDisplayDataList' plug-in function to report back a list of tools to check for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 415
diff changeset
1062 elif hasattr(module, "exeDisplayData"):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1063 infos.append(module.exeDisplayData())
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1064 for module in (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1065 list(self.__onDemandActiveModules.values()) +
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1066 list(self.__onDemandInactiveModules.values())
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
1067 ):
438
f62a3f9d2e28 Changed code to include Qt Help tools in programs detection and introduced the 'exeDisplayDataList' plug-in function to report back a list of tools to check for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 415
diff changeset
1068 if hasattr(module, "exeDisplayDataList"):
f62a3f9d2e28 Changed code to include Qt Help tools in programs detection and introduced the 'exeDisplayDataList' plug-in function to report back a list of tools to check for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 415
diff changeset
1069 infos.extend(module.exeDisplayDataList())
f62a3f9d2e28 Changed code to include Qt Help tools in programs detection and introduced the 'exeDisplayDataList' plug-in function to report back a list of tools to check for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 415
diff changeset
1070 elif hasattr(module, "exeDisplayData"):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1071 infos.append(module.exeDisplayData())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1072
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1073 return infos
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1074
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1075 def getPluginConfigData(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1076 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1077 Public method to get the config data of all active, non on-demand
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1078 plugins used by the configuration dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1079
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1080 Plugins supporting this functionality must provide the plugin module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1081 function 'getConfigData' returning a dictionary with unique keys
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1082 of lists with the following list contents:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1083 <dl>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1084 <dt>display string</dt>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1085 <dd>string shown in the selection area of the configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086 This should be a localized string</dd>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1087 <dt>pixmap name</dt>
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1088 <dd>filename of the pixmap to be shown next to the display
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1089 string</dd>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1090 <dt>page creation function</dt>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1091 <dd>plugin module function to be called to create the configuration
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1092 page. The page must be subclasses from
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1093 Preferences.ConfigurationPages.ConfigurationPageBase and must
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1094 implement a method called 'save' to save the settings. A parent
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1095 entry will be created in the selection list, if this value is
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1096 None.</dd>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff