def check_input(variable, expected_type, name, or_none=False):
    """
    Checks if a given variable is of the expected type. May also be
    NoneType is or_none is True. Raises an exception if any issues are
    encountered.

    :param variable: variable to check type of
    :param expected_type: expected type of the provided variable
    :param name: name of the variable, used to make clearer debug messages
    :param or_none: (optional) boolean of if the variable can be unset.
    Default value is False
    :return: returns nothing
    """
    if not variable and expected_type is not bool and or_none is False:
        raise Exception('variable %s was not given' % name)
    if not expected_type:
        raise Exception("'expected_type' %s was not given" % expected_type)
    if not or_none:
        if not isinstance(variable, expected_type):
            raise Exception('Expected %s type was %s, got %s' % (name,
                expected_type, type(variable)))
    elif not isinstance(variable, expected_type) and not isinstance(variable,
        type(None)):
        raise Exception('Expected %s type was %s or None, got %s' % (name,
            expected_type, type(variable)))
