def parseBoolValue(value, fail_on_errors=True, preserve_none=False):
 if (not isinstance(value, string_type)):
  if (preserve_none and (value is None)):
   return value
  return bool(value)
 elif (preserve_none and (value.lower() == u'none')):
  return None
 elif (value.lower() in (u'true', u'yes', u'y', u'on', u'1')):
  return True
 elif (value.lower() in (u'false', u'no', u'n', u'off', u'0', u'none')):
  return False
 elif fail_on_errors:
  raise ValueError((u'Cannot parse bool value: %r' % value))

def parseBoolValue ( value , fail_on_errors = True , preserve_none = False ) : if ( not isinstance ( value , string_type ) ) : if ( preserve_none and ( value is None ) ) : return value return bool ( value ) elif ( preserve_none and ( value . lower ( ) == u'none' ) ) : return None elif ( value . lower ( ) in ( u'true' , u'yes' , u'y' , u'on' , u'1' ) ) : return True elif ( value . lower ( ) in ( u'false' , u'no' , u'n' , u'off' , u'0' , u'none' ) ) : return False elif fail_on_errors : raise ValueError ( ( u'Cannot parse bool value: %r' % value ) )
parses a string representing bool value .