<s> """<STR_LIT>""" <EOL> from jasmin . routing . Interceptors import Interceptor <EOL> from jasmin . routing . Routables import Routable <EOL> class InvalidInterceptionTableParameterError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class InterceptionTable ( object ) : <EOL> """<STR_LIT>""" <EOL> type = '<STR_LIT>' <EOL> def __init__ ( self ) : <EOL> self . table = [ ] <EOL> def add ( self , interceptor , order ) : <EOL> if not isinstance ( interceptor , Interceptor ) : <EOL> raise InvalidInterceptionTableParameterError ( "<STR_LIT>" ) <EOL> if not isinstance ( order , int ) : <EOL> raise InvalidInterceptionTableParameterError ( "<STR_LIT>" ) <EOL> if self . type == '<STR_LIT>' and interceptor . script . type != '<STR_LIT>' : <EOL> raise InvalidInterceptionTableParameterError ( "<STR_LIT>" , <EOL> interceptor . script . type ) <EOL> elif self . type == '<STR_LIT>' and interceptor . script . type != '<STR_LIT>' : <EOL> raise InvalidInterceptionTableParameterError ( "<STR_LIT>" , <EOL> interceptor . script . type ) <EOL> if order < <NUM_LIT:0> : <EOL> raise InvalidInterceptionTableParameterError ( "<STR_LIT>" ) <EOL> if order != <NUM_LIT:0> and interceptor . type != self . type : <EOL> raise InvalidInterceptionTableParameterError ( "<STR_LIT>" , <EOL> self . type , interceptor . type ) <EOL> if order == <NUM_LIT:0> and interceptor . type != '<STR_LIT:default>' : <EOL> raise InvalidInterceptionTableParameterError ( <EOL> "<STR_LIT>" ) <EOL> self . remove ( order ) <EOL> self . table . append ( { order : interceptor } ) <EOL> self . table . sort ( reverse = True ) <EOL> def remove ( self , order ) : <EOL> for r in self . table : <EOL> if r . keys ( ) [ <NUM_LIT:0> ] == order : <EOL> self . table . remove ( r ) <EOL> return True <EOL> return False <EOL> def getAll ( self ) : <EOL> return self . table <EOL> def flush ( self ) : <EOL> self . table = [ ] <EOL> def getInterceptorFor ( self , routable ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( routable , Routable ) : <EOL> raise InvalidInterceptionTableParameterError ( "<STR_LIT>" ) <EOL> for r in self . table : <EOL> interceptor = r . values ( ) [ <NUM_LIT:0> ] <EOL> if interceptor . matchFilters ( routable ) : <EOL> return interceptor <EOL> return None <EOL> class MTInterceptionTable ( InterceptionTable ) : <EOL> "<STR_LIT>" <EOL> type = '<STR_LIT>' <EOL> class MOInterceptionTable ( InterceptionTable ) : <EOL> "<STR_LIT>" <EOL> type = '<STR_LIT>' </s>
