@staticmethod
def sanitize_bool(value, field_name):
    'Convert the given value to a bool.\n\n        :param value: Either True, False,, "1", "0", 1 or 0.\n        :type value: :py:class:`basestring` | :py:class:`bool` | :py:class:`int`\n        :param field_name: Name of the field this value belongs to (just for debug messages).\n        :type field_name: basestring\n        :return: The bool value of the given value.\n        :rtype: :py:class:`bool`\n        :raises: :py:exc:`ValueError` if the given value is not supported in this conversion.\n        '
    if (value not in (True, False, '1', '0', 1, 0)):
        raise ValueError(('%s is not a valid value for %s.' % (str(value), field_name)))
    if (value == '0'):
        return False
    return bool(value)
Convert the given value to a bool.

:param value: Either True, False,, "1", "0", 1 or 0.
:type value: :py:class:`basestring` | :py:class:`bool` | :py:class:`int`
:param field_name: Name of the field this value belongs to (just for debug messages).
:type field_name: basestring
:return: The bool value of the given value.
:rtype: :py:class:`bool`
:raises: :py:exc:`ValueError` if the given value is not supported in this conversion.
@staticmethod
def sanitize_bool(value, field_name):
    'Convert the given value to a bool.\n\n        :param value: Either True, False,, "1", "0", 1 or 0.\n        :type value: :py:class:`basestring` | :py:class:`bool` | :py:class:`int`\n        :param field_name: Name of the field this value belongs to (just for debug messages).\n        :type field_name: basestring\n        :return: The bool value of the given value.\n        :rtype: :py:class:`bool`\n        :raises: :py:exc:`ValueError` if the given value is not supported in this conversion.\n        '
    if (value not in (True, False, '1', '0', 1, 0)):
        raise ValueError(('%s is not a valid value for %s.' % (str(value), field_name)))
    if (value == '0'):
        return False
    return bool(value)