<s> """<STR_LIT>""" <EOL> from operator import attrgetter <EOL> from functools import update_wrapper <EOL> __all__ = [ '<STR_LIT>' ] <EOL> class _IffHasAttrDescriptor ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , fn , attribute_name ) : <EOL> self . fn = fn <EOL> self . get_attribute = attrgetter ( attribute_name ) <EOL> update_wrapper ( self , fn ) <EOL> def __get__ ( self , obj , type = None ) : <EOL> if obj is not None : <EOL> self . get_attribute ( obj ) <EOL> out = lambda * args , ** kwargs : self . fn ( obj , * args , ** kwargs ) <EOL> update_wrapper ( out , self . fn ) <EOL> return out <EOL> def if_delegate_has_method ( delegate ) : <EOL> """<STR_LIT>""" <EOL> return lambda fn : _IffHasAttrDescriptor ( fn , '<STR_LIT>' % ( delegate , fn . __name__ ) ) </s>
