def Boolean():
    """
    Creates a validator that attempts to convert the given value to a boolean
    or raises an error. The following rules are used:

    ``None`` is converted to ``False``.

    ``int`` values are ``True`` except for ``0``.

    ``str`` values converted in lower- and uppercase:

    * ``y, yes, t, true``
    * ``n, no, f, false``
    """
    @wraps(Boolean)
    def built(value):
        # Already a boolean?
        if isinstance(value, bool):
            return value

        # None
        if value == None:
            return False

        # Integers
        if isinstance(value, int):
            return not value == 0

        # Strings
        if isinstance(value, str):
            if value.lower() in { 'y', 'yes', 't', 'true' }:
                return True
            elif value.lower() in { 'n', 'no', 'f', 'false' }:
                return False

        # Nope
        raise Error("Not a boolean value.")
    return built
def Boolean ( ) : @ wraps ( Boolean ) def built ( value ) : if isinstance ( value , bool ) : return value if value == None : return False if isinstance ( value , int ) : return not value == 0 if isinstance ( value , str ) : if value . lower ( ) in { 'y' , 'yes' , 't' , 'true' } : return True elif value . lower ( ) in { 'n' , 'no' , 'f' , 'false' } : return False raise Error ( "Not a boolean value." ) return built
Creates a validator that attempts to convert the given value to a boolean
    or raises an error. The following rules are used:

    ``None`` is converted to ``False``.

    ``int`` values are ``True`` except for ``0``.

    ``str`` values converted in lower- and uppercase:

    * ``y, yes, t, true``
    * ``n, no, f, false``