<s> from __future__ import absolute_import <EOL> import inspect <EOL> import warnings <EOL> class RemovedInDjango20Warning ( PendingDeprecationWarning ) : <EOL> pass <EOL> class RemovedInNextVersionWarning ( DeprecationWarning ) : <EOL> pass <EOL> class warn_about_renamed_method ( object ) : <EOL> def __init__ ( self , class_name , old_method_name , new_method_name , deprecation_warning ) : <EOL> self . class_name = class_name <EOL> self . old_method_name = old_method_name <EOL> self . new_method_name = new_method_name <EOL> self . deprecation_warning = deprecation_warning <EOL> def __call__ ( self , f ) : <EOL> def wrapped ( * args , ** kwargs ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" % <EOL> ( self . class_name , self . old_method_name , self . new_method_name ) , <EOL> self . deprecation_warning , <NUM_LIT:2> ) <EOL> return f ( * args , ** kwargs ) <EOL> return wrapped <EOL> class RenameMethodsBase ( type ) : <EOL> """<STR_LIT>""" <EOL> renamed_methods = ( ) <EOL> def __new__ ( cls , name , bases , attrs ) : <EOL> new_class = super ( RenameMethodsBase , cls ) . __new__ ( cls , name , bases , attrs ) <EOL> for base in inspect . getmro ( new_class ) : <EOL> class_name = base . __name__ <EOL> for renamed_method in cls . renamed_methods : <EOL> old_method_name = renamed_method [ <NUM_LIT:0> ] <EOL> old_method = base . __dict__ . get ( old_method_name ) <EOL> new_method_name = renamed_method [ <NUM_LIT:1> ] <EOL> new_method = base . __dict__ . get ( new_method_name ) <EOL> deprecation_warning = renamed_method [ <NUM_LIT:2> ] <EOL> wrapper = warn_about_renamed_method ( class_name , * renamed_method ) <EOL> if not new_method and old_method : <EOL> warnings . warn ( <EOL> "<STR_LIT>" % <EOL> ( class_name , old_method_name , new_method_name ) , <EOL> deprecation_warning , <NUM_LIT:2> ) <EOL> setattr ( base , new_method_name , old_method ) <EOL> setattr ( base , old_method_name , wrapper ( old_method ) ) <EOL> if not old_method and new_method : <EOL> setattr ( base , old_method_name , wrapper ( new_method ) ) <EOL> return new_class <EOL> class DeprecationInstanceCheck ( type ) : <EOL> def __instancecheck__ ( self , instance ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" % ( self . __name__ , self . alternative ) , <EOL> self . deprecation_warning , <NUM_LIT:2> <EOL> ) <EOL> return super ( DeprecationInstanceCheck , self ) . __instancecheck__ ( instance ) <EOL> class CallableBool : <EOL> """<STR_LIT>""" <EOL> do_not_call_in_templates = True <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __bool__ ( self ) : <EOL> return self . value <EOL> def __call__ ( self ) : <EOL> warnings . warn ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> RemovedInDjango20Warning , stacklevel = <NUM_LIT:2> <EOL> ) <EOL> return self . value <EOL> def __nonzero__ ( self ) : <EOL> return self . value <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . value <EOL> CallableFalse = CallableBool ( False ) <EOL> CallableTrue = CallableBool ( True ) </s>
