eric6/PluginManager/PluginManager.py

Sun, 01 Sep 2019 19:40:53 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 01 Sep 2019 19:40:53 +0200
branch
without_py2_and_pyqt4
changeset 7198
684261ef2165
parent 7192
a22eee00b052
child 7229
53054eb5b15a
permissions
-rw-r--r--

Removed the Qt4 runtime stuff.

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