#NEWLINE# def filter_preconditions( classes , logger = None ) : #NEWLINE# #INDENT# 'Filter handlers whose preconditions are not met\n\n    classes: list of nogotofail handler classes to filter\n    logger: logging.Logger to optionally log the failure message of handlers whose preconditions are not met.\n    Returns list of classes whose preconditions are met\n    ' #NEWLINE# filtered = [ ] #NEWLINE# for cls in classes : #NEWLINE# #INDENT# ( status , message ) = cls . check_precondition ( ) #NEWLINE# if status : #NEWLINE# #INDENT# filtered . append ( cls ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( logger is not None ) : #NEWLINE# #INDENT# logger . warning ( 'Disabling handler %s because preconditions not met: %s.' , classes . name , message ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return filtered