def search_by_name(service, name, **kwargs):
 if ('search' in inspect.getargspec(service.list)[0]):
  res = service.list(search='name={name}'.format(name=name))
 else:
  res = [e for e in service.list() if (e.name == name)]
 if kwargs:
  res = [e for e in service.list() if (len([k for (k, v) in kwargs.items() if (getattr(e, k, None) == v)]) == len(kwargs))]
 res = (res or [None])
 return res[0]

def search_by_name ( service , name , ** kwargs ) : if ( 'search' in inspect . getargspec ( service . list ) [ 0 ] ) : res = service . list ( search = 'name={name}' . format ( name = name ) ) else : res = [ e for e in service . list ( ) if ( e . name == name ) ] if kwargs : res = [ e for e in service . list ( ) if ( len ( [ k for ( k , v ) in kwargs . items ( ) if ( getattr ( e , k , None ) == v ) ] ) == len ( kwargs ) ) ] res = ( res or [ None ] ) return res [ 0 ]
search for the entity by its name .