human
Complete this python program:
def deprecated(since=None, message=None):
assistant
#Here is the Python code you requested.

    """Decorator for marking a function deprecated. Generates a warning on
    standard output if the function is called.
    Usage:
    .. python::
    from grizzled.decorators import deprecated
    class MyClass(object):
    @deprecated()
    def oldMethod(self):
    pass
    Given the above declaration, the following code will cause a
    warning to be printed (though the method call will otherwise succeed):
    .. python::
    obj = MyClass()
    obj.oldMethod()
    You may also specify a ``since`` argument, used to display a deprecation
    message with a version stamp (e.g., \deprecated since ...\):
    .. python::
    from grizzled.decorators import deprecated
    class MyClass(object):
    @deprecated(since=\1.2\)
    def oldMethod(self):
    pass
    :Parameters:
    since : str
    version stamp, or ``None`` for none
    message : str
    optional additional message to print
    """
    def decorator(func):
        if (since is None):
            buf = ('Method    %s    is    deprecated.' % func.__name__)
        else:
            buf = ('Method    %s    has    been    deprecated    since    version    %s.' % (func.__name__, since))
        if message:
            buf += ('    ' + message)
        def wrapper(*__args, **__kw):
            import warnings
            warnings.warn(buf, category=DeprecationWarning, stacklevel=2)
            return func(*__args, **__kw)
        wrapper.__name__ = func.__name__
        wrapper.__dict__ = func.__dict__
        wrapper.__doc__ = func.__doc__
        return wrapper
    return decorator