<s> from basicconfig import ConfigHolder <EOL> class MethodHolder ( ConfigHolder ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , method = None , ** kwargs ) : <EOL> super ( MethodHolder , self ) . __init__ ( ) <EOL> if method is None : <EOL> return <EOL> elif type ( method ) is str : <EOL> self . __dict__ [ "<STR_LIT>" ] = method <EOL> self . lock ( ) <EOL> self . update ( kwargs ) <EOL> elif type ( method ) is _UnboundMethodType : <EOL> self . __dict__ [ "<STR_LIT>" ] = method . im_func . func_name <EOL> varnames = list ( method . im_func . func_code . co_varnames ) [ : method . im_func . func_code . co_argcount ] <EOL> varnames . reverse ( ) <EOL> df = method . im_func . func_defaults or [ ] <EOL> defaults = list ( df ) ; defaults . reverse ( ) <EOL> for name , deflt in map ( None , varnames , defaults ) : <EOL> self [ name ] = deflt <EOL> del self [ varnames [ - <NUM_LIT:1> ] ] <EOL> self . lock ( ) <EOL> self . update ( kwargs ) <EOL> else : <EOL> raise ValueError , "<STR_LIT>" <EOL> def __str__ ( self ) : <EOL> m = self . __dict__ [ "<STR_LIT>" ] <EOL> params = "<STR_LIT:U+002CU+0020>" . join ( [ "<STR_LIT>" % ( n , v ) for n , v in self . items ( ) ] ) <EOL> return "<STR_LIT>" % ( m , params ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self . __dict__ [ "<STR_LIT>" ] , <EOL> "<STR_LIT:U+002CU+0020>" . join ( [ "<STR_LIT>" % ( n , v ) for n , v in self . items ( ) ] ) ) <EOL> def _methodname ( self ) : <EOL> return self . __dict__ [ "<STR_LIT>" ] <EOL> methodname = property ( _methodname , None , None , "<STR_LIT>" ) <EOL> def __call__ ( self , instance ) : <EOL> meth = getattr ( instance , self . __dict__ [ "<STR_LIT>" ] ) <EOL> return apply ( meth , ( ) , self ) <EOL> def copy ( self ) : <EOL> new = MethodHolder ( ) <EOL> for key , val in self . items ( ) : <EOL> new [ key ] = val <EOL> new . __dict__ [ "<STR_LIT>" ] = self . __dict__ [ "<STR_LIT>" ] <EOL> new . lock ( ) <EOL> return new <EOL> def update ( self , other ) : <EOL> for k in other . keys ( ) : <EOL> self [ k ] = other [ k ] <EOL> _UnboundMethodType = type ( MethodHolder . copy ) <EOL> def _test ( argv ) : <EOL> class TestMe ( object ) : <EOL> def mymethod ( self , arg1 = <NUM_LIT:1> , arg2 = <NUM_LIT:2> , arg3 = <NUM_LIT:3> ) : <EOL> print arg1 , arg2 , arg3 <EOL> mh = MethodHolder ( TestMe . mymethod ) <EOL> print mh <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import sys <EOL> _test ( sys . argv ) </s>
