#NEWLINE# def deprecate_kwarg( old_name , new_name , kw_value ) : #NEWLINE# #INDENT# "\n    Rename keyword arguments, but keep backwards compatibility.\n\n    Usage:\n\n    .. code-block: python\n\n        >>> @deprecate_kwarg('old', 'new', 'defval')\n        ... def some_func(old='defval'):\n        ...     print(old)\n        ...\n        >>> some_func(new='yay')\n        yay\n        >>> some_func(old='yaay')\n        yaay\n        >>> some_func()\n        defval\n\n    " #NEWLINE# def real_decorator( function ) : #NEWLINE# #INDENT# def new_function( * args , **kwargs ) : #NEWLINE# #INDENT# value = kw_value #NEWLINE# if ( old_name in kwargs ) : #NEWLINE# #INDENT# warnings . warn ( 'Keyword argument {0} is deprecated, use {1}' . format ( old_name , new_name ) ) #NEWLINE# value = kwargs [ old_name ] #NEWLINE# #UNINDENT# if ( new_name in kwargs ) : #NEWLINE# #INDENT# value = kwargs [ new_name ] #NEWLINE# del kwargs [ new_name ] #NEWLINE# #UNINDENT# kwargs [ old_name ] = value #NEWLINE# return function ( * args , ** kwargs ) #NEWLINE# #UNINDENT# return new_function #NEWLINE# #UNINDENT# return real_decorator