<s> '''<STR_LIT>''' <EOL> import functools <EOL> from ovs . extensions . db . arakoon . pyrakoon . pyrakoon import protocol , utils <EOL> def validate_types ( specs , args ) : <EOL> '''<STR_LIT>''' <EOL> for spec , arg in zip ( specs , args ) : <EOL> name , type_ = spec [ : <NUM_LIT:2> ] <EOL> try : <EOL> type_ . check ( arg ) <EOL> except TypeError : <EOL> raise TypeError ( '<STR_LIT>' % name ) <EOL> except ValueError : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> def call ( message_type ) : <EOL> '''<STR_LIT>''' <EOL> def wrapper ( fun ) : <EOL> '''<STR_LIT>''' <EOL> has_consistency = False <EOL> argspec = [ '<STR_LIT>' ] <EOL> for arg in message_type . ARGS : <EOL> if arg is protocol . CONSISTENCY_ARG : <EOL> has_consistency = True <EOL> continue <EOL> if len ( arg ) == <NUM_LIT:2> : <EOL> argspec . append ( arg [ <NUM_LIT:0> ] ) <EOL> elif len ( arg ) == <NUM_LIT:3> : <EOL> argspec . append ( ( arg [ <NUM_LIT:0> ] , arg [ <NUM_LIT:2> ] ) ) <EOL> else : <EOL> raise ValueError <EOL> if has_consistency : <EOL> name , _ , default = protocol . CONSISTENCY_ARG <EOL> argspec . append ( ( name , default ) ) <EOL> @ utils . update_argspec ( * argspec ) <EOL> @ functools . wraps ( fun ) <EOL> def wrapped ( ** kwargs ) : <EOL> self = kwargs [ '<STR_LIT>' ] <EOL> if not self . connected : <EOL> from ovs . extensions . db . arakoon . pyrakoon . pyrakoon import client <EOL> raise client . NotConnectedError ( '<STR_LIT>' ) <EOL> args = tuple ( kwargs [ arg [ <NUM_LIT:0> ] ] for arg in message_type . ARGS ) <EOL> validate_types ( message_type . ARGS , args ) <EOL> message = message_type ( * args ) <EOL> return self . _process ( message ) <EOL> wrapped . __doc__ = message_type . DOC <EOL> return wrapped <EOL> return wrapper </s>
