This is a decorator which can be used to mark functions
    as deprecated. It will result in a warning being emitted
    when the function is used.

def deprecated(func):
    '''This is a decorator which can be used to mark functions
    as deprecated. It will result in a warning being emitted
    when the function is used.'''

    import warnings

    @functools.wraps(func)
    def new_func(*args, **kwargs):
        if is_python_3:
            code = func.__code__
        else:
            code = func.func_code
        warnings.warn_explicit(
            "Call to deprecated function {}.".format(func.__name__),
            category=Warning,
            filename=code.co_filename,
            lineno=code.co_firstlineno + 1
        )
        return func(*args, **kwargs)
    return new_func