import warnings
import functools


__all__ = ['deprecated']


class deprecated(object):
    '''Decorator to mark deprecated functions with warning.

    Adapted from <http://wiki.python.org/moin/PythonDecoratorLibrary>.

    Parameters
    ----------
    alt_func : str
        If given, tell user what function to use instead.
    behavior : {'warn', 'raise'}
        Behavior during call to deprecated function: 'warn' = warn user that
        function is deprecated; 'raise' = raise error.
    '''

    def __init__(self, alt_func=None, behavior='warn'):
        self.alt_func = alt_func
        self.behavior = behavior

    def __call__(self, func):

        msg = 'Call to deprecated function `%s`.' % func.__name__
        if self.alt_func is not None:
            msg += ' Use `%s` instead.' % self.alt_func

        @functools.wraps(func)
        def wrapped(*args, **kwargs):
            if self.behavior == 'warn':
                warnings.warn_explicit(msg,
                    category=DeprecationWarning,
                    filename=func.func_code.co_filename,
                    lineno=func.func_code.co_firstlineno + 1)
            elif self.behavior == 'raise':
                raise DeprecationWarning(msg)
            return func(*args, **kwargs)

        # modify doc string to display deprecation warning
        doc = 'Deprecated function.'
        if self.alt_func is not None:
            doc += ' Use `%s` instead.' % self.alt_func

        if wrapped.__doc__ is None:
            wrapped.__doc__ = doc
        else:
            wrapped.__doc__ = doc + '\n\n' + wrapped.__doc__

        return wrapped

@@ -661,65 +661,20 @@
     
+alt_
 msg = '
-Call to deprecated function %60%25s%60.' %25 func.__name__
+'
 %0A   
@@ -724,13 +724,16 @@
     
+alt_
 msg 
-+
 = ' 
@@ -760,32 +760,122 @@
  self.alt_func%0A%0A
+        msg = 'Call to deprecated function %60%25s%60.' %25 func.__name__%0A        msg += alt_msg%0A%0A
         @functoo
@@ -1409,103 +1409,18 @@
 on.'
-%0A        if self.alt_func is not None:%0A            doc += ' Use %60%25s%60 instead.' %25 self.alt_func%0A
+ + alt_msg
 %0A   

Remove duplicate code for alternative function