#NEWLINE# def should_exclude( entity , include , exclude ) : #NEWLINE# #INDENT# if ( ( entity is not None ) and ( entity . strip ( ) != '' ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# for pattern in include : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# compiled = re . compile ( pattern , re . IGNORECASE ) #NEWLINE# if compiled . search ( entity ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# except re . error as ex : #NEWLINE# #INDENT# log . warning ( u ( 'Regex error ({msg}) for include pattern: {pattern}' ) . format ( msg = u ( ex ) , pattern = u ( pattern ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except TypeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# for pattern in exclude : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# compiled = re . compile ( pattern , re . IGNORECASE ) #NEWLINE# if compiled . search ( entity ) : #NEWLINE# #INDENT# return pattern #NEWLINE# #UNINDENT# #UNINDENT# except re . error as ex : #NEWLINE# #INDENT# log . warning ( u ( 'Regex error ({msg}) for exclude pattern: {pattern}' ) . format ( msg = u ( ex ) , pattern = u ( pattern ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except TypeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# return False