<s> """<STR_LIT>""" <EOL> import warnings <EOL> WARN_ONLY = True <EOL> message = """<STR_LIT>""" <EOL> class DeprecatedPropertyError ( Exception ) : <EOL> pass <EOL> class DeprecatedProperty ( object ) : <EOL> def __init__ ( self , instance , method ) : <EOL> self . instance = instance <EOL> self . method = method <EOL> def call ( self ) : <EOL> return self . method ( self . instance ) <EOL> def call_and_notify ( self ) : <EOL> method = self . method <EOL> method_name = method . __name__ <EOL> if WARN_ONLY : <EOL> warnings . warn ( message % method_name ) <EOL> return self . call ( ) <EOL> else : <EOL> raise DeprecatedPropertyError ( message % method_name ) <EOL> def __call__ ( self ) : <EOL> return self . call ( ) <EOL> def __nonzero__ ( self ) : <EOL> value = self . call_and_notify ( ) <EOL> return bool ( value ) <EOL> def __bool__ ( self ) : <EOL> return self . __nonzero__ ( ) <EOL> def __eq__ ( self , other ) : <EOL> value = self . call_and_notify ( ) <EOL> return value == other <EOL> def __ne__ ( self , other ) : <EOL> return not ( self == other ) <EOL> class DeprecatedPropertyDescriptor ( object ) : <EOL> def __init__ ( self , method ) : <EOL> self . method = method <EOL> def __get__ ( self , instance , owner ) : <EOL> return DeprecatedProperty ( instance , self . method ) <EOL> deprecated_property = DeprecatedPropertyDescriptor </s>
