def check_whitelist_blacklist(value, whitelist=None, blacklist=None):
 if (blacklist is not None):
  if (not hasattr(blacklist, '__iter__')):
   blacklist = [blacklist]
  try:
   for expr in blacklist:
    if expr_match(value, expr):
     return False
  except TypeError:
   log.error('Non-iterable blacklist {0}'.format(blacklist))
 if whitelist:
  if (not hasattr(whitelist, '__iter__')):
   whitelist = [whitelist]
  try:
   for expr in whitelist:
    if expr_match(value, expr):
     return True
  except TypeError:
   log.error('Non-iterable whitelist {0}'.format(whitelist))
 else:
  return True
 return False

def check_whitelist_blacklist ( value , whitelist = None , blacklist = None ) : if ( blacklist is not None ) : if ( not hasattr ( blacklist , '__iter__' ) ) : blacklist = [ blacklist ] try : for expr in blacklist : if expr_match ( value , expr ) : return False except TypeError : log . error ( 'Non-iterable blacklist {0}' . format ( blacklist ) ) if whitelist : if ( not hasattr ( whitelist , '__iter__' ) ) : whitelist = [ whitelist ] try : for expr in whitelist : if expr_match ( value , expr ) : return True except TypeError : log . error ( 'Non-iterable whitelist {0}' . format ( whitelist ) ) else : return True return False
check a whitelist and/or blacklist to see if the value matches it .