sbsv2/raptor/python/filter_list.py
branchfix
changeset 533 408bfff46ad7
parent 3 e1eecf4d390d
child 534 3b10c85868b1
equal deleted inserted replaced
532:1083c9a3a7cf 533:408bfff46ad7
    79 			Returns: Boolean: Have the functions succeeded in opening the files?
    79 			Returns: Boolean: Have the functions succeeded in opening the files?
    80 		"""
    80 		"""
    81 		# Find all the filter plugins
    81 		# Find all the filter plugins
    82 		self.pbox = pbox
    82 		self.pbox = pbox
    83 		possiblefilters = self.pbox.classesof(filter_interface.Filter)
    83 		possiblefilters = self.pbox.classesof(filter_interface.Filter)
       
    84 		filterdict = {}
       
    85 		for p in possiblefilters:
       
    86 			name = p.__name__.lower()
       
    87 			if name in filterdict:
       
    88 				raise ValueError("filters found in SBS_HOME/python/plugins which have duplicate name: %s " % p.__name__)
       
    89 			else:
       
    90 				filterdict[name] = p
       
    91 
    84 		unfound = []
    92 		unfound = []
    85 		self.filters = []
    93 		self.filters = []
    86 		for f in filternames:
    94 		for f in filternames:
    87 			unfound.append(f) # unfound unless we find it
    95 			found = False
    88 			for pl in possiblefilters:
    96 			if f.lower() in filterdict:
    89 				if pl.__name__.upper() == f.upper():
    97 				self.filters.append(filterdict[f.lower()])
    90 					self.filters.append(pl())
    98 			else:
    91 					unfound = unfound[:-1]
    99 				unfound.append(f)
       
   100 
    92 		if unfound != []:
   101 		if unfound != []:
    93 			raise ValueError("requested filters not found: %s \
   102 			raise ValueError("requested filters not found: %s \
    94 			\nAvailable filters are: %s" % (str(unfound), self.format_output_list(possiblefilters)))
   103 			\nAvailable filters are: %s" % (str(unfound), self.format_output_list(possiblefilters)))
    95 
   104 
    96 		if self.filters == []:
   105 		if self.filters == []: