174 |
175 |
175 def finalizeSetup(self): |
176 def finalizeSetup(self): |
176 """ |
177 """ |
177 Public method to finalize the setup of the plugin manager. |
178 Public method to finalize the setup of the plugin manager. |
178 """ |
179 """ |
179 for module in list(self.__onDemandInactiveModules.values()) + list( |
180 for module in itertools.chain( |
180 self.__onDemandActiveModules.values() |
181 self.__onDemandInactiveModules.values(), |
|
182 self.__onDemandActiveModules.values(), |
181 ): |
183 ): |
182 if hasattr(module, "moduleSetup"): |
184 if hasattr(module, "moduleSetup"): |
183 module.moduleSetup() |
185 module.moduleSetup() |
184 |
186 |
185 def getPluginDir(self, key): |
187 def getPluginDir(self, key): |
536 """ |
538 """ |
537 Public method to create plugin objects for all on demand plugins. |
539 Public method to create plugin objects for all on demand plugins. |
538 |
540 |
539 Note: The plugins are not activated. |
541 Note: The plugins are not activated. |
540 """ |
542 """ |
541 names = sorted(self.__onDemandInactiveModules.keys()) |
543 names = sorted(self.__onDemandInactiveModules) |
542 for name in names: |
544 for name in names: |
543 self.initOnDemandPlugin(name) |
545 self.initOnDemandPlugin(name) |
544 |
546 |
545 def initOnDemandPlugin(self, name): |
547 def initOnDemandPlugin(self, name): |
546 """ |
548 """ |
600 if ( |
602 if ( |
601 self.__develPluginName is not None |
603 self.__develPluginName is not None |
602 and self.__develPluginName in inactiveList |
604 and self.__develPluginName in inactiveList |
603 ): |
605 ): |
604 inactiveList.remove(self.__develPluginName) |
606 inactiveList.remove(self.__develPluginName) |
605 names = sorted(self.__inactiveModules.keys()) |
607 names = sorted(self.__inactiveModules) |
606 for name in names: |
608 for name in names: |
607 if name not in inactiveList: |
609 if name not in inactiveList: |
608 self.activatePlugin(name) |
610 self.activatePlugin(name) |
609 self.allPlugginsActivated.emit() |
611 self.allPlugginsActivated.emit() |
610 |
612 |
789 already |
791 already |
790 @type bool |
792 @type bool |
791 @return reference to the initialized plugin object and an error string |
793 @return reference to the initialized plugin object and an error string |
792 @rtype tuple of (QObject, str) |
794 @rtype tuple of (QObject, str) |
793 """ |
795 """ |
794 for name, module in list(self.__onDemandInactiveModules.items()): |
796 for name, module in self.__onDemandInactiveModules.items(): |
795 if ( |
797 if ( |
796 getPluginHeaderEntry(module, "pluginType", "") == type_ |
798 getPluginHeaderEntry(module, "pluginType", "") == type_ |
797 and getPluginHeaderEntry(module, "pluginTypename", "") == typename |
799 and getPluginHeaderEntry(module, "pluginTypename", "") == typename |
798 ): |
800 ): |
799 return self.activatePlugin(name, onDemand=True) |
801 return self.activatePlugin(name, onDemand=True) |
800 |
802 |
801 if maybeActive: |
803 if maybeActive: |
802 for name, module in list(self.__onDemandActiveModules.items()): |
804 for name, module in self.__onDemandActiveModules.items(): |
803 if ( |
805 if ( |
804 getPluginHeaderEntry(module, "pluginType", "") == type_ |
806 getPluginHeaderEntry(module, "pluginType", "") == type_ |
805 and getPluginHeaderEntry(module, "pluginTypename", "") == typename |
807 and getPluginHeaderEntry(module, "pluginTypename", "") == typename |
806 ): |
808 ): |
807 self.deactivatePlugin(name, onDemand=True) |
809 self.deactivatePlugin(name, onDemand=True) |
820 "short_desc": str, "error": bool) |
822 "short_desc": str, "error": bool) |
821 """ |
823 """ |
822 infos = [] |
824 infos = [] |
823 |
825 |
824 # 1. active, non-on-demand modules |
826 # 1. active, non-on-demand modules |
825 for name in list(self.__activeModules.keys()): |
827 for name in self.__activeModules: |
826 info = self.__getShortInfo(self.__activeModules[name]) |
828 info = self.__getShortInfo(self.__activeModules[name]) |
827 info.update( |
829 info.update( |
828 { |
830 { |
829 "module_name": name, |
831 "module_name": name, |
830 "auto_activate": True, |
832 "auto_activate": True, |
832 } |
834 } |
833 ) |
835 ) |
834 infos.append(info) |
836 infos.append(info) |
835 |
837 |
836 # 2. inactive, non-on-demand modules |
838 # 2. inactive, non-on-demand modules |
837 for name in list(self.__inactiveModules.keys()): |
839 for name in self.__inactiveModules: |
838 info = self.__getShortInfo(self.__inactiveModules[name]) |
840 info = self.__getShortInfo(self.__inactiveModules[name]) |
839 info.update( |
841 info.update( |
840 { |
842 { |
841 "module_name": name, |
843 "module_name": name, |
842 "auto_activate": True, |
844 "auto_activate": True, |
844 } |
846 } |
845 ) |
847 ) |
846 infos.append(info) |
848 infos.append(info) |
847 |
849 |
848 # 3. active, on-demand modules |
850 # 3. active, on-demand modules |
849 for name in list(self.__onDemandActiveModules.keys()): |
851 for name in self.__onDemandActiveModules: |
850 info = self.__getShortInfo(self.__onDemandActiveModules[name]) |
852 info = self.__getShortInfo(self.__onDemandActiveModules[name]) |
851 info.update( |
853 info.update( |
852 { |
854 { |
853 "module_name": name, |
855 "module_name": name, |
854 "auto_activate": False, |
856 "auto_activate": False, |
856 } |
858 } |
857 ) |
859 ) |
858 infos.append(info) |
860 infos.append(info) |
859 |
861 |
860 # 4. inactive, non-on-demand modules |
862 # 4. inactive, non-on-demand modules |
861 for name in list(self.__onDemandInactiveModules.keys()): |
863 for name in self.__onDemandInactiveModules: |
862 info = self.__getShortInfo(self.__onDemandInactiveModules[name]) |
864 info = self.__getShortInfo(self.__onDemandInactiveModules[name]) |
863 info.update( |
865 info.update( |
864 { |
866 { |
865 "module_name": name, |
867 "module_name": name, |
866 "auto_activate": False, |
868 "auto_activate": False, |
972 @return dictionary with name as key and display string as value |
974 @return dictionary with name as key and display string as value |
973 @rtype dict |
975 @rtype dict |
974 """ |
976 """ |
975 pluginDict = {} |
977 pluginDict = {} |
976 |
978 |
977 for module in list(self.__onDemandActiveModules.values()) + list( |
979 for module in itertools.chain( |
978 self.__onDemandInactiveModules.values() |
980 self.__onDemandActiveModules.values(), |
|
981 self.__onDemandInactiveModules.values(), |
979 ): |
982 ): |
980 if ( |
983 if ( |
981 getPluginHeaderEntry(module, "pluginType", "") == type_ |
984 getPluginHeaderEntry(module, "pluginType", "") == type_ |
982 and getPluginHeaderEntry(module, "error", "") == "" |
985 and getPluginHeaderEntry(module, "error", "") == "" |
983 ): |
986 ): |
998 @param name name of the plugin type |
1001 @param name name of the plugin type |
999 @type str |
1002 @type str |
1000 @return preview pixmap |
1003 @return preview pixmap |
1001 @rtype QPixmap |
1004 @rtype QPixmap |
1002 """ |
1005 """ |
1003 for module in list(self.__onDemandActiveModules.values()) + list( |
1006 for module in itertools.chain( |
1004 self.__onDemandInactiveModules.values() |
1007 self.__onDemandActiveModules.values(), |
|
1008 self.__onDemandInactiveModules.values(), |
1005 ): |
1009 ): |
1006 if ( |
1010 if ( |
1007 getPluginHeaderEntry(module, "pluginType", "") == type_ |
1011 getPluginHeaderEntry(module, "pluginType", "") == type_ |
1008 and getPluginHeaderEntry(module, "pluginTypename", "") == name |
1012 and getPluginHeaderEntry(module, "pluginTypename", "") == name |
1009 ): |
1013 ): |
1023 @return list of API filenames |
1027 @return list of API filenames |
1024 @rtype list of str |
1028 @rtype list of str |
1025 """ |
1029 """ |
1026 apis = [] |
1030 apis = [] |
1027 |
1031 |
1028 for module in list(self.__activeModules.values()) + list( |
1032 for module in itertools.chain( |
1029 self.__onDemandActiveModules.values() |
1033 self.__activeModules.values(), |
|
1034 self.__onDemandActiveModules.values(), |
1030 ): |
1035 ): |
1031 if hasattr(module, "apiFiles"): |
1036 if hasattr(module, "apiFiles"): |
1032 apis.extend(module.apiFiles(language)) |
1037 apis.extend(module.apiFiles(language)) |
1033 |
1038 |
1034 return apis |
1039 return apis |
1041 @return dictionary with documentation type as key and list of files |
1046 @return dictionary with documentation type as key and list of files |
1042 as value |
1047 as value |
1043 @rtype dict (key: str, value: list of str) |
1048 @rtype dict (key: str, value: list of str) |
1044 """ |
1049 """ |
1045 helpFiles = {} |
1050 helpFiles = {} |
1046 for module in list(self.__activeModules.values()) + list( |
1051 for module in itertools.chain( |
1047 self.__onDemandActiveModules.values() |
1052 self.__activeModules.values(), |
|
1053 self.__onDemandActiveModules.values(), |
1048 ): |
1054 ): |
1049 if hasattr(module, "helpFiles"): |
1055 if hasattr(module, "helpFiles"): |
1050 helpFiles.update(module.helpFiles()) |
1056 helpFiles.update(module.helpFiles()) |
1051 |
1057 |
1052 return helpFiles |
1058 return helpFiles |
1086 </ul> |
1092 </ul> |
1087 @rtype list of dict |
1093 @rtype list of dict |
1088 """ |
1094 """ |
1089 infos = [] |
1095 infos = [] |
1090 |
1096 |
1091 for module in list(self.__activeModules.values()) + list( |
1097 for module in itertools.chain( |
1092 self.__inactiveModules.values() |
1098 self.__activeModules.values(), |
1093 ): |
1099 self.__inactiveModules.values(), |
1094 if hasattr(module, "exeDisplayDataList"): |
1100 self.__onDemandActiveModules.values(), |
1095 infos.extend(module.exeDisplayDataList()) |
1101 self.__onDemandInactiveModules.values(), |
1096 elif hasattr(module, "exeDisplayData"): |
|
1097 infos.append(module.exeDisplayData()) |
|
1098 for module in list(self.__onDemandActiveModules.values()) + list( |
|
1099 self.__onDemandInactiveModules.values() |
|
1100 ): |
1102 ): |
1101 if hasattr(module, "exeDisplayDataList"): |
1103 if hasattr(module, "exeDisplayDataList"): |
1102 infos.extend(module.exeDisplayDataList()) |
1104 infos.extend(module.exeDisplayDataList()) |
1103 elif hasattr(module, "exeDisplayData"): |
1105 elif hasattr(module, "exeDisplayData"): |
1104 infos.append(module.exeDisplayData()) |
1106 infos.append(module.exeDisplayData()) |
1137 |
1139 |
1138 @return plug-in configuration data |
1140 @return plug-in configuration data |
1139 @rtype dict |
1141 @rtype dict |
1140 """ |
1142 """ |
1141 configData = {} |
1143 configData = {} |
1142 for module in ( |
1144 for module in itertools.chain( |
1143 list(self.__activeModules.values()) |
1145 self.__activeModules.values(), |
1144 + list(self.__onDemandActiveModules.values()) |
1146 self.__onDemandActiveModules.values(), |
1145 + list(self.__onDemandInactiveModules.values()) |
1147 self.__onDemandInactiveModules.values(), |
1146 ): |
1148 ): |
1147 if hasattr(module, "getConfigData"): |
1149 if hasattr(module, "getConfigData"): |
1148 configData.update(module.getConfigData()) |
1150 configData.update(module.getConfigData()) |
1149 return configData |
1151 return configData |
1150 |
1152 |
1199 string (str). |
1201 string (str). |
1200 @rtype dict |
1202 @rtype dict |
1201 """ |
1203 """ |
1202 vcsDict = {} |
1204 vcsDict = {} |
1203 |
1205 |
1204 for module in list(self.__onDemandActiveModules.values()) + list( |
1206 for module in itertools.chain( |
1205 self.__onDemandInactiveModules.values() |
1207 self.__onDemandActiveModules.values(), |
|
1208 self.__onDemandInactiveModules.values(), |
1206 ): |
1209 ): |
1207 if getPluginHeaderEntry( |
1210 if getPluginHeaderEntry( |
1208 module, "pluginType", "" |
1211 module, "pluginType", "" |
1209 ) == "version_control" and hasattr(module, "getVcsSystemIndicator"): |
1212 ) == "version_control" and hasattr(module, "getVcsSystemIndicator"): |
1210 res = module.getVcsSystemIndicator() |
1213 res = module.getVcsSystemIndicator() |
1211 for indicator, vcsData in list(res.items()): |
1214 for indicator, vcsData in res.items(): |
1212 if indicator in vcsDict: |
1215 if indicator in vcsDict: |
1213 vcsDict[indicator].append(vcsData) |
1216 vcsDict[indicator].append(vcsData) |
1214 else: |
1217 else: |
1215 vcsDict[indicator] = [vcsData] |
1218 vcsDict[indicator] = [vcsData] |
1216 |
1219 |
1483 clearPrivateData() and have the module level attribute pluginType. |
1486 clearPrivateData() and have the module level attribute pluginType. |
1484 |
1487 |
1485 @param type_ type of the plugin to clear private data for |
1488 @param type_ type of the plugin to clear private data for |
1486 @type str |
1489 @type str |
1487 """ |
1490 """ |
1488 for module in ( |
1491 for module in itertools.chain( |
1489 list(self.__onDemandActiveModules.values()) |
1492 self.__onDemandActiveModules.values(), |
1490 + list(self.__onDemandInactiveModules.values()) |
1493 self.__onDemandInactiveModules.values(), |
1491 + list(self.__activeModules.values()) |
1494 self.__activeModules.values(), |
1492 + list(self.__inactiveModules.values()) |
1495 self.__inactiveModules.values(), |
1493 ): |
1496 ): |
1494 if getPluginHeaderEntry(module, "pluginType", "") == type_ and hasattr( |
1497 if getPluginHeaderEntry(module, "pluginType", "") == type_ and hasattr( |
1495 module, "clearPrivateData" |
1498 module, "clearPrivateData" |
1496 ): |
1499 ): |
1497 module.clearPrivateData() |
1500 module.clearPrivateData() |