def validate_ternary(setting, value, option_parser, config_parser=None, config_section=None):
 if (isinstance(value, bool) or (value is None)):
  return value
 try:
  return option_parser.booleans[value.strip().lower()]
 except KeyError:
  return value

def validate_ternary ( setting , value , option_parser , config_parser = None , config_section = None ) : if ( isinstance ( value , bool ) or ( value is None ) ) : return value try : return option_parser . booleans [ value . strip ( ) . lower ( ) ] except KeyError : return value
check/normalize three-value settings: true: 1 .