(self, search_criteria)
return list(l)
return a list of clients corresponding to the search criteria. ex: platform:*win*
return a list of clients corresponding to the search criteria. ex: platform:*win*
return a list of clients corresponding to the search criteria . ex : platform : * win *
def get_clients(self, search_criteria):
		""" return a list of clients corresponding to the search criteria. ex: platform:*win* """ 
		#if the criteria is a simple id we return the good client
		try:
			index=int(search_criteria)
			for c in self.clients:
				if int(c.desc["id"])==index:
					return [c]
			return []
		except Exception:
			pass
		l=set([])
		if search_criteria=="*":
			return self.clients
		for c in self.clients:
			take=False
			for sc in search_criteria.split():
				tab=sc.split(":",1)
				if len(tab)==2 and tab[0] in [x for x in c.desc.iterkeys()]:#if the field is specified we search for the value in this field
					take=True
					if not tab[1].lower() in str(c.desc[tab[0]]).lower():
						take=False
						break
				elif len(tab)!=2:#if there is no field specified we search in every field for at least one match
					take=False
					for k,v in c.desc.iteritems():
						if type(v) is unicode or type(v) is str:
							if tab[0].lower() in v.decode('utf8').lower():
								take=True
								break
						else:
							if tab[0].lower() in str(v).decode('utf8').lower():
								take=True
								break
					if not take:
						break
			if take:
				l.add(c)
		return list(l)
def get_clients ( self , search_criteria ) : #if the criteria is a simple id we return the good client try : index = int ( search_criteria ) for c in self . clients : if int ( c . desc [ "id" ] ) == index : return [ c ] return [ ] except Exception : pass l = set ( [ ] ) if search_criteria == "*" : return self . clients for c in self . clients : take = False for sc in search_criteria . split ( ) : tab = sc . split ( ":" , 1 ) if len ( tab ) == 2 and tab [ 0 ] in [ x for x in c . desc . iterkeys ( ) ] : #if the field is specified we search for the value in this field take = True if not tab [ 1 ] . lower ( ) in str ( c . desc [ tab [ 0 ] ] ) . lower ( ) : take = False break elif len ( tab ) != 2 : #if there is no field specified we search in every field for at least one match take = False for k , v in c . desc . iteritems ( ) : if type ( v ) is unicode or type ( v ) is str : if tab [ 0 ] . lower ( ) in v . decode ( 'utf8' ) . lower ( ) : take = True break else : if tab [ 0 ] . lower ( ) in str ( v ) . decode ( 'utf8' ) . lower ( ) : take = True break if not take : break if take : l . add ( c ) return list ( l )