<s> """<STR_LIT>""" <EOL> import inspect <EOL> from thespian . actors import Actor <EOL> def Actorize ( cls ) : <EOL> def receiveMessage ( self , message , sender ) : <EOL> klass = message . __class__ <EOL> registry = self . _msg_registry <EOL> if not klass in registry : <EOL> for k in registry : <EOL> if isinstance ( message , k ) : <EOL> registry [ klass ] = registry [ k ] <EOL> break <EOL> method = registry . get ( klass , None ) <EOL> if method is not None : <EOL> method ( self , message , sender ) <EOL> else : <EOL> super ( cls , self ) . receiveMessage ( message , sender ) <EOL> assert issubclass ( cls , Actor ) , "<STR_LIT>" <EOL> assert '<STR_LIT>' in vars ( cls ) , "<STR_LIT>" <EOL> cls . receiveMessage = receiveMessage <EOL> if not hasattr ( cls , '<STR_LIT>' ) : <EOL> cls . _msg_registry = { } <EOL> for name , method in inspect . getmembers ( cls , predicate = inspect . ismethod ) : <EOL> if hasattr ( method , '<STR_LIT>' ) : <EOL> for klass in method . handles : <EOL> cls . _msg_registry [ klass ] = method <EOL> return cls <EOL> def handle ( klass ) : <EOL> def wrapper ( f ) : <EOL> f . handles = getattr ( f , '<STR_LIT>' , [ ] ) + [ klass ] <EOL> return f <EOL> return wrapper </s>
