예제 #1
0
	def OnApply(self, event):
		""" Method called by PreferenceGUI class.
				- Active plug-in through pluginmanager
				- Write the plug-in list in the DEVSimPy config file
		"""

		### list of plug-in names which are to write in DEVSimPy config file
		pluginsList = []
		### all listed plug-ins
		for i in range(self.GetItemCount()):
			module = self.GetPyData(i)[0]
			if inspect.ismodule(module):
				### plug-in file path
				path = module.__file__
				### built-in module coming from empty module create by error manager
				if path:
					### get abspath and exclude .pyc
					name,ext = os.path.splitext(os.path.basename(path))
					### if plug-in is checked, we activate it
					
					if self.IsChecked(i):
						pluginsList.append(name)
						PluginManager.enable_plugin(name)
					else:
						PluginManager.disable_plugin(name)

		### config file writing
		self.mainW.cfg.Write('active_plugins', str(pluginsList))
		self.mainW.cfg.Flush()
예제 #2
0
	def Importing(self, root, basename):
		""" Importing module and set pydata object
		"""

		# check the loaded module during the start of plug-ins
		module = PluginManager.load_plugins(basename)

		### if module is exception (or tuple)
		if not inspect.ismodule(module):
			error = str(module)
			module = types.ModuleType(basename)
			module.__doc__ = error
			module.__file__ = None

		index = self.MyInsertItem(root, basename)

		if index is not None:
			if module.__file__ != None:
				### only module to be activated is checked
				if basename in self.active_plugins_list:
					self.CheckItem(index, True)
					self.SetItemImage(index,1)
				else:
					PluginManager.disable_plugin(basename)
			else:
				self.SetItemImage(index, 2)

			#### pyData setting
			self.SetPyData(index, (module, None))