def _filter_values(vals, vlist=None, must=False):
 if (not vlist):
  return vals
 if isinstance(vlist, basestring):
  vlist = [vlist]
 res = []
 for val in vlist:
  if (val in vals):
   res.append(val)
 if must:
  if res:
   return res
  else:
   raise MissingValue('Required attribute value missing')
 else:
  return res

def _filter_values ( vals , vlist = None , must = False ) : if ( not vlist ) : return vals if isinstance ( vlist , basestring ) : vlist = [ vlist ] res = [ ] for val in vlist : if ( val in vals ) : res . append ( val ) if must : if res : return res else : raise MissingValue ( 'Required attribute value missing' ) else : return res
removes values from *vals* that does not appear in vlist .