PluginManager/PluginManager.py

changeset 3036
30c81c9e88b8
parent 3034
7ce719013078
child 3060
5883ce99ee12
child 3112
9485059ea9fa
equal deleted inserted replaced
3035:36e9f388958b 3036:30c81c9e88b8
78 self.__inactivePluginsKey = "PluginManager/InactivePlugins" 78 self.__inactivePluginsKey = "PluginManager/InactivePlugins"
79 79
80 self.pluginDirs = { 80 self.pluginDirs = {
81 "eric5": os.path.join(getConfig('ericDir'), "Plugins"), 81 "eric5": os.path.join(getConfig('ericDir'), "Plugins"),
82 "global": os.path.join(Utilities.getPythonModulesDirectory(), 82 "global": os.path.join(Utilities.getPythonModulesDirectory(),
83 "eric5plugins"), 83 "eric5plugins"),
84 "user": os.path.join(Utilities.getConfigDir(), "eric5plugins"), 84 "user": os.path.join(Utilities.getConfigDir(), "eric5plugins"),
85 } 85 }
86 self.__priorityOrder = ["eric5", "global", "user"] 86 self.__priorityOrder = ["eric5", "global", "user"]
87 87
88 self.__defaultDownloadDir = os.path.join( 88 self.__defaultDownloadDir = os.path.join(
121 def finalizeSetup(self): 121 def finalizeSetup(self):
122 """ 122 """
123 Public method to finalize the setup of the plugin manager. 123 Public method to finalize the setup of the plugin manager.
124 """ 124 """
125 for module in list(self.__onDemandInactiveModules.values()) + \ 125 for module in list(self.__onDemandInactiveModules.values()) + \
126 list(self.__onDemandActiveModules.values()): 126 list(self.__onDemandActiveModules.values()):
127 if hasattr(module, "moduleSetup"): 127 if hasattr(module, "moduleSetup"):
128 module.moduleSetup() 128 module.moduleSetup()
129 129
130 def getPluginDir(self, key): 130 def getPluginDir(self, key):
131 """ 131 """
767 """ 767 """
768 pluginDict = {} 768 pluginDict = {}
769 769
770 for name, module in \ 770 for name, module in \
771 list(self.__onDemandActiveModules.items()) + \ 771 list(self.__onDemandActiveModules.items()) + \
772 list(self.__onDemandInactiveModules.items()): 772 list(self.__onDemandInactiveModules.items()):
773 if getattr(module, "pluginType") == type_ and \ 773 if getattr(module, "pluginType") == type_ and \
774 getattr(module, "error", "") == "": 774 getattr(module, "error", "") == "":
775 plugin_name = getattr(module, "pluginTypename") 775 plugin_name = getattr(module, "pluginTypename")
776 if hasattr(module, "displayString"): 776 if hasattr(module, "displayString"):
777 try: 777 try:
793 @param name name of the plugin type (string) 793 @param name name of the plugin type (string)
794 @return preview pixmap (QPixmap) 794 @return preview pixmap (QPixmap)
795 """ 795 """
796 for modname, module in \ 796 for modname, module in \
797 list(self.__onDemandActiveModules.items()) + \ 797 list(self.__onDemandActiveModules.items()) + \
798 list(self.__onDemandInactiveModules.items()): 798 list(self.__onDemandInactiveModules.items()):
799 if getattr(module, "pluginType") == type_ and \ 799 if getattr(module, "pluginType") == type_ and \
800 getattr(module, "pluginTypename") == name: 800 getattr(module, "pluginTypename") == name:
801 if hasattr(module, "previewPix"): 801 if hasattr(module, "previewPix"):
802 return module.previewPix() 802 return module.previewPix()
803 else: 803 else:
813 @return list of API filenames (list of string) 813 @return list of API filenames (list of string)
814 """ 814 """
815 apis = [] 815 apis = []
816 816
817 for module in list(self.__activeModules.values()) + \ 817 for module in list(self.__activeModules.values()) + \
818 list(self.__onDemandActiveModules.values()): 818 list(self.__onDemandActiveModules.values()):
819 if hasattr(module, "apiFiles"): 819 if hasattr(module, "apiFiles"):
820 apis.extend(module.apiFiles(language)) 820 apis.extend(module.apiFiles(language))
821 821
822 return apis 822 return apis
823 823
856 </ul> 856 </ul>
857 """ 857 """
858 infos = [] 858 infos = []
859 859
860 for module in list(self.__activeModules.values()) + \ 860 for module in list(self.__activeModules.values()) + \
861 list(self.__inactiveModules.values()): 861 list(self.__inactiveModules.values()):
862 if hasattr(module, "exeDisplayDataList"): 862 if hasattr(module, "exeDisplayDataList"):
863 infos.extend(module.exeDisplayDataList()) 863 infos.extend(module.exeDisplayDataList())
864 elif hasattr(module, "exeDisplayData"): 864 elif hasattr(module, "exeDisplayData"):
865 infos.append(module.exeDisplayData()) 865 infos.append(module.exeDisplayData())
866 for module in list(self.__onDemandActiveModules.values()) + \ 866 for module in list(self.__onDemandActiveModules.values()) + \
867 list(self.__onDemandInactiveModules.values()): 867 list(self.__onDemandInactiveModules.values()):
868 if hasattr(module, "exeDisplayDataList"): 868 if hasattr(module, "exeDisplayDataList"):
869 infos.extend(module.exeDisplayDataList()) 869 infos.extend(module.exeDisplayDataList())
870 elif hasattr(module, "exeDisplayData"): 870 elif hasattr(module, "exeDisplayData"):
871 infos.append(module.exeDisplayData()) 871 infos.append(module.exeDisplayData())
872 872
904 904
905 @return plug-in configuration data 905 @return plug-in configuration data
906 """ 906 """
907 configData = {} 907 configData = {}
908 for module in list(self.__activeModules.values()) + \ 908 for module in list(self.__activeModules.values()) + \
909 list(self.__onDemandActiveModules.values()) + \ 909 list(self.__onDemandActiveModules.values()) + \
910 list(self.__onDemandInactiveModules.values()): 910 list(self.__onDemandInactiveModules.values()):
911 if hasattr(module, 'getConfigData'): 911 if hasattr(module, 'getConfigData'):
912 configData.update(module.getConfigData()) 912 configData.update(module.getConfigData())
913 return configData 913 return configData
914 914
915 def isPluginLoaded(self, pluginName): 915 def isPluginLoaded(self, pluginName):
918 918
919 @param pluginName name of the plugin to check for (string) 919 @param pluginName name of the plugin to check for (string)
920 @return flag indicating, if the plugin is loaded (boolean) 920 @return flag indicating, if the plugin is loaded (boolean)
921 """ 921 """
922 return pluginName in self.__activeModules or \ 922 return pluginName in self.__activeModules or \
923 pluginName in self.__inactiveModules or \ 923 pluginName in self.__inactiveModules or \
924 pluginName in self.__onDemandActiveModules or \ 924 pluginName in self.__onDemandActiveModules or \
925 pluginName in self.__onDemandInactiveModules 925 pluginName in self.__onDemandInactiveModules
926 926
927 def isPluginActive(self, pluginName): 927 def isPluginActive(self, pluginName):
928 """ 928 """
929 Public method to check, if a certain plugin is active. 929 Public method to check, if a certain plugin is active.
930 930
931 @param pluginName name of the plugin to check for (string) 931 @param pluginName name of the plugin to check for (string)
932 @return flag indicating, if the plugin is active (boolean) 932 @return flag indicating, if the plugin is active (boolean)
933 """ 933 """
934 return pluginName in self.__activeModules or \ 934 return pluginName in self.__activeModules or \
935 pluginName in self.__onDemandActiveModules 935 pluginName in self.__onDemandActiveModules
936 936
937 ########################################################################### 937 ###########################################################################
938 ## Specialized plugin module handling methods below 938 ## Specialized plugin module handling methods below
939 ########################################################################### 939 ###########################################################################
940 940
956 """ 956 """
957 vcsDict = {} 957 vcsDict = {}
958 958
959 for name, module in \ 959 for name, module in \
960 list(self.__onDemandActiveModules.items()) + \ 960 list(self.__onDemandActiveModules.items()) + \
961 list(self.__onDemandInactiveModules.items()): 961 list(self.__onDemandInactiveModules.items()):
962 if getattr(module, "pluginType") == "version_control": 962 if getattr(module, "pluginType") == "version_control":
963 if hasattr(module, "getVcsSystemIndicator"): 963 if hasattr(module, "getVcsSystemIndicator"):
964 res = module.getVcsSystemIndicator() 964 res = module.getVcsSystemIndicator()
965 for indicator, vcsData in list(res.items()): 965 for indicator, vcsData in list(res.items()):
966 if indicator in vcsDict: 966 if indicator in vcsDict:
1003 self.trUtf8( 1003 self.trUtf8(
1004 """<p>The plugin download directory""" 1004 """<p>The plugin download directory"""
1005 """ <b>{0}</b> could not be created. Please""" 1005 """ <b>{0}</b> could not be created. Please"""
1006 """ configure it via the configuration""" 1006 """ configure it via the configuration"""
1007 """ dialog.</p><p>Reason: {1}</p>""") 1007 """ dialog.</p><p>Reason: {1}</p>""")
1008 .format(downloadDir, str(err))) 1008 .format(downloadDir, str(err)))
1009 downloadDir = "" 1009 downloadDir = ""
1010 1010
1011 Preferences.setPluginManager("DownloadPath", downloadDir) 1011 Preferences.setPluginManager("DownloadPath", downloadDir)
1012 1012
1013 def preferencesChanged(self): 1013 def preferencesChanged(self):

eric ide

mercurial