def validate_bool_maybe_none(b):
 if isinstance(b, six.string_types):
  b = b.lower()
 if ((b is None) or (b == u'none')):
  return None
 if (b in (u't', u'y', u'yes', u'on', u'true', u'1', 1, True)):
  return True
 elif (b in (u'f', u'n', u'no', u'off', u'false', u'0', 0, False)):
  return False
 else:
  raise ValueError((u'Could not convert "%s" to boolean' % b))

def validate_bool_maybe_none ( b ) : if isinstance ( b , six . string_types ) : b = b . lower ( ) if ( ( b is None ) or ( b == u'none' ) ) : return None if ( b in ( u't' , u'y' , u'yes' , u'on' , u'true' , u'1' , 1 , True ) ) : return True elif ( b in ( u'f' , u'n' , u'no' , u'off' , u'false' , u'0' , 0 , False ) ) : return False else : raise ValueError ( ( u'Could not convert "%s" to boolean' % b ) )
convert b to a boolean or raise .