Exemple #1
0
	def _parse_collection (self, name, node):
		dict = {}
		for i in node.childNodes:
			if i.nodeName == "value":
				try:
					id = i.attributes ["id"].nodeValue
					min, max, ide = None, None, None
					
					if i.attributes.has_key ("min"):
						min = float (i.attributes ["min"].nodeValue)
					if i.attributes.has_key ("max"):
						max = float (i.attributes ["max"].nodeValue)
					if i.attributes.has_key ("ideal"):
						ide = float (i.attributes ["ideal"].nodeValue)
					
					dict [id] = (min, max, ide)
				except:
					utils.c_error ("Float error in %s" % id)
		
		if len (dict) > 0:
			self.collection [name] = dict
Exemple #2
0
	def load (self, path, name, klass):
		# Aggiungiamo la path
		old = sys.path
		sys.path.append (path)
		
			#utils.c_warn ("Carico il modulo senza try/except.. fixami prima della revisione finale")
		try:
			module = __import__ (name)#, globals (), locals (), [klass])
			instance = vars(module)[klass]

			for i in self.array:
				if i.__class__ == instance:
					return False
			
			plugin = instance ()
			
			# Roba di preferenze... raccomandati di merda -.- gh
			
			for i in plugin.__preferences__:
				ret = impostazioni.get (i)
				
				if ret == None:
					impostazioni.set (i, plugin.__preferences__[i])
				else:
					if type (ret) == type (plugin.__preferences__[i]):
						plugin.__preferences__[i] = ret
			
			plugin.start ()
			
			self.array.append (plugin)
			
			sys.path = old

			return True
		except:
			utils.c_warn ("Restoring path")
			sys.path = old

			utils.c_error ("!! %s::%s (%s)" % (klass, sys.exc_value, sys.exc_type))
			return False