<s> """<STR_LIT>""" <EOL> import warnings <EOL> from warnings import formatwarning , linecache <EOL> def formatwarning ( message , category , filename , lineno , line = None ) : <EOL> """<STR_LIT>""" <EOL> if issubclass ( category , ExecutionWarning ) : <EOL> s = u"<STR_LIT>" % ( category . __name__ , message ) <EOL> else : <EOL> s = u'<STR_LIT>' % ( category . __name__ , message , lineno , filename ) <EOL> return s <EOL> warnings . formatwarning = formatwarning <EOL> class ExecutionWarning ( UserWarning ) : <EOL> """<STR_LIT>""" <EOL> def warn ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( args ) == <NUM_LIT:1> and not isinstance ( args [ <NUM_LIT:0> ] , Warning ) : <EOL> args = args + ( ExecutionWarning , ) <EOL> stacklevel = kwargs . pop ( "<STR_LIT>" , <NUM_LIT:1> ) + <NUM_LIT:1> <EOL> return warnings . warn ( stacklevel = stacklevel , * args , ** kwargs ) <EOL> def deprecated ( funcOrMessage , className = None ) : <EOL> """<STR_LIT>""" <EOL> def deprecated2 ( func ) : <EOL> info = dict ( <EOL> name = func . __name__ , <EOL> module = func . __module__ ) <EOL> def deprecationLoggedFunc ( * args , ** kwargs ) : <EOL> warnings . warn ( message % info , DeprecationWarning , stacklevel = <NUM_LIT:2> ) <EOL> return func ( * args , ** kwargs ) <EOL> deprecationLoggedFunc . __name__ = func . __name__ <EOL> deprecationLoggedFunc . __module__ = func . __module__ <EOL> deprecationLoggedFunc . __doc__ = message % info + '<STR_LIT:\n>' <EOL> if func . __doc__ : <EOL> deprecationLoggedFunc . __doc__ += '<STR_LIT:\n>' + func . __doc__ <EOL> return deprecationLoggedFunc <EOL> if className : <EOL> objName = '<STR_LIT>' + className + '<STR_LIT>' <EOL> else : <EOL> objName = '<STR_LIT>' <EOL> basemessage = message = "<STR_LIT>" + objName + "<STR_LIT>" <EOL> if isinstance ( funcOrMessage , basestring ) : <EOL> message = basemessage + '<STR_LIT>' + funcOrMessage <EOL> return deprecated2 <EOL> else : <EOL> message = basemessage <EOL> return deprecated2 ( funcOrMessage ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import doctest <EOL> doctest . testmod ( ) </s>
