示例#1
0
文件: __init__.py 项目: kthulhu/mrv
	def plugin_unloaded(self, pluginName):
		"""Remove all node types registered by pluginName unless they have been 
		registered by a third party. We cannot assume that they listen to these events, 
		hence we just keep the record as it will not harm.
		
		In any way, we will remove any record of the plugin from our db"""
		self.log.debug("plugin '%s' unloaded" % pluginName)
		
		# clear our record
		installed_type_names = self[pluginName]
		del(self[pluginName])
		
		# deregister types if possible
		nt = globals()
		for tn in installed_type_names:
			tnc = capitalize(tn)
			
			try:
				node_type = nt[tnc]
			except KeyError:
				# wasnt registered anymore ? 
				self.log.warn("Type %s of unloaded plugin %s was already de-registered in mrv type system - skipped" % (tnc, pluginName)) 
				continue
			# END handle exception
			
			# remove the type only if it was one of our unknown default types
			parentclsname = node_type.__base__.__name__
			if not parentclsname.startswith('Unknown'):
				continue
			# END skip custom nodes
			
			typ._removeCustomType(nt, tnc)
示例#2
0
文件: __init__.py 项目: kthulhu/mrv
def removeCustomType( customType ):
	"""Removes the given type from this module as well as from the type hierarchy.
	This makes it unavailble to MRV
	
	:param customType: either string identifying the type's name or the type itself
	:note: does nothing if the type does not exist"""
	if not isinstance(customType, basestring):
		customType = customType.__name__
	typ._removeCustomType(globals(), customType)