<s> """<STR_LIT>""" <EOL> from _functools import partial , reduce <EOL> WRAPPER_ASSIGNMENTS = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> WRAPPER_UPDATES = ( '<STR_LIT>' , ) <EOL> def update_wrapper ( wrapper , <EOL> wrapped , <EOL> assigned = WRAPPER_ASSIGNMENTS , <EOL> updated = WRAPPER_UPDATES ) : <EOL> """<STR_LIT>""" <EOL> for attr in assigned : <EOL> setattr ( wrapper , attr , getattr ( wrapped , attr ) ) <EOL> for attr in updated : <EOL> getattr ( wrapper , attr ) . update ( getattr ( wrapped , attr , { } ) ) <EOL> return wrapper <EOL> def wraps ( wrapped , <EOL> assigned = WRAPPER_ASSIGNMENTS , <EOL> updated = WRAPPER_UPDATES ) : <EOL> """<STR_LIT>""" <EOL> return partial ( update_wrapper , wrapped = wrapped , <EOL> assigned = assigned , updated = updated ) <EOL> def total_ordering ( cls ) : <EOL> """<STR_LIT>""" <EOL> convert = { <EOL> '<STR_LIT>' : [ ( '<STR_LIT>' , lambda self , other : not ( self < other or self == other ) ) , <EOL> ( '<STR_LIT>' , lambda self , other : self < other or self == other ) , <EOL> ( '<STR_LIT>' , lambda self , other : not self < other ) ] , <EOL> '<STR_LIT>' : [ ( '<STR_LIT>' , lambda self , other : not self <= other or self == other ) , <EOL> ( '<STR_LIT>' , lambda self , other : self <= other and not self == other ) , <EOL> ( '<STR_LIT>' , lambda self , other : not self <= other ) ] , <EOL> '<STR_LIT>' : [ ( '<STR_LIT>' , lambda self , other : not ( self > other or self == other ) ) , <EOL> ( '<STR_LIT>' , lambda self , other : self > other or self == other ) , <EOL> ( '<STR_LIT>' , lambda self , other : not self > other ) ] , <EOL> '<STR_LIT>' : [ ( '<STR_LIT>' , lambda self , other : ( not self >= other ) or self == other ) , <EOL> ( '<STR_LIT>' , lambda self , other : self >= other and not self == other ) , <EOL> ( '<STR_LIT>' , lambda self , other : not self >= other ) ] <EOL> } <EOL> roots = set ( dir ( cls ) ) & set ( convert ) <EOL> if not roots : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> root = max ( roots ) <EOL> for opname , opfunc in convert [ root ] : <EOL> if opname not in roots : <EOL> opfunc . __name__ = opname <EOL> opfunc . __doc__ = getattr ( int , opname ) . __doc__ <EOL> setattr ( cls , opname , opfunc ) <EOL> return cls <EOL> def cmp_to_key ( mycmp ) : <EOL> """<STR_LIT>""" <EOL> class K ( object ) : <EOL> __slots__ = [ '<STR_LIT>' ] <EOL> def __init__ ( self , obj , * args ) : <EOL> self . obj = obj <EOL> def __lt__ ( self , other ) : <EOL> return mycmp ( self . obj , other . obj ) < <NUM_LIT:0> <EOL> def __gt__ ( self , other ) : <EOL> return mycmp ( self . obj , other . obj ) > <NUM_LIT:0> <EOL> def __eq__ ( self , other ) : <EOL> return mycmp ( self . obj , other . obj ) == <NUM_LIT:0> <EOL> def __le__ ( self , other ) : <EOL> return mycmp ( self . obj , other . obj ) <= <NUM_LIT:0> <EOL> def __ge__ ( self , other ) : <EOL> return mycmp ( self . obj , other . obj ) >= <NUM_LIT:0> <EOL> def __ne__ ( self , other ) : <EOL> return mycmp ( self . obj , other . obj ) != <NUM_LIT:0> <EOL> def __hash__ ( self ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> return K </s>
