import warnings


def _deprecated(callable, msg=None):
    """
    Create a wrapper function that will raise a DeprecationWarning
    before calling the callable.
    """
    if msg is None:
        msg = "%s is deprecated" % callable
    def deprecatedWrapper(*args, **kwargs):
        warnings.warn(msg, DeprecationWarning, stacklevel=2)
        return callable(*args, **kwargs)
    deprecatedWrapper.__doc__ = msg
    return deprecatedWrapper