def _decorate_with_warning(func, wtype, message, docstring_header=None):
 message = _sanitize_restructured_text(message)
 @decorator
 def warned(fn, *args, **kwargs):
  warnings.warn(wtype(message), stacklevel=3)
  return fn(*args, **kwargs)
 doc = (((func.__doc__ is not None) and func.__doc__) or '')
 if (docstring_header is not None):
  docstring_header %= dict(func=func.__name__)
  doc = inject_docstring_text(doc, docstring_header, 1)
 decorated = warned(func)
 decorated.__doc__ = doc
 return decorated

def _decorate_with_warning ( func , wtype , message , docstring_header = None ) : message = _sanitize_restructured_text ( message ) @ decorator def warned ( fn , * args , ** kwargs ) : warnings . warn ( wtype ( message ) , stacklevel = 3 ) return fn ( * args , ** kwargs ) doc = ( ( ( func . __doc__ is not None ) and func . __doc__ ) or '' ) if ( docstring_header is not None ) : docstring_header %= dict ( func = func . __name__ ) doc = inject_docstring_text ( doc , docstring_header , 1 ) decorated = warned ( func ) decorated . __doc__ = doc return decorated
wrap a function with a warnings .