<s> class SourceFactory : <EOL> """<STR_LIT>""" <EOL> sources = { <EOL> "<STR_LIT>" : [ ] , <EOL> "<STR_LIT>" : [ ] , <EOL> "<STR_LIT>" : [ ] , <EOL> "<STR_LIT>" : [ ] <EOL> } <EOL> @ classmethod <EOL> def register_sources ( self , sources ) : <EOL> for source in sources : <EOL> for target in source . targets : <EOL> for action in source . actions : <EOL> self . register_a_source ( target , action , source ) <EOL> @ classmethod <EOL> def register_a_source ( self , target , action , source ) : <EOL> key = "<STR_LIT>" % ( target , action ) <EOL> self . sources [ key ] . append ( source ) <EOL> @ classmethod <EOL> def _get_generic_source ( self , target , action , ** keywords ) : <EOL> key = "<STR_LIT>" % ( target , action ) <EOL> for source in self . sources [ key ] : <EOL> if source . is_my_business ( action , ** keywords ) : <EOL> s = source ( ** keywords ) <EOL> return s <EOL> return None <EOL> @ classmethod <EOL> def get_source ( self , ** keywords ) : <EOL> return self . _get_generic_source ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ** keywords ) <EOL> @ classmethod <EOL> def get_book_source ( self , ** keywords ) : <EOL> return self . _get_generic_source ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ** keywords ) <EOL> @ classmethod <EOL> def get_writeable_source ( self , ** keywords ) : <EOL> return self . _get_generic_source ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ** keywords ) <EOL> @ classmethod <EOL> def get_writeable_book_source ( self , ** keywords ) : <EOL> return self . _get_generic_source ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ** keywords ) </s>
