<s> from thrift . protocol . TProtocol import TProtocolBase <EOL> from types import * <EOL> class TProtocolDecorator ( ) : <EOL> def __init__ ( self , protocol ) : <EOL> TProtocolBase ( protocol ) <EOL> self . protocol = protocol <EOL> def __getattr__ ( self , name ) : <EOL> if hasattr ( self . protocol , name ) : <EOL> member = getattr ( self . protocol , name ) <EOL> if type ( member ) in [ MethodType , UnboundMethodType , FunctionType , LambdaType , BuiltinFunctionType , BuiltinMethodType ] : <EOL> return lambda * args , ** kwargs : self . _wrap ( member , args , kwargs ) <EOL> else : <EOL> return member <EOL> raise AttributeError ( name ) <EOL> def _wrap ( self , func , args , kwargs ) : <EOL> if type ( func ) == MethodType : <EOL> result = func ( * args , ** kwargs ) <EOL> else : <EOL> result = func ( self . protocol , * args , ** kwargs ) <EOL> return result </s>
