<s> """<STR_LIT>""" <EOL> from . managers import AlchemyModelManager <EOL> from . routers import ReadOnlyRouter <EOL> from . viewsets import AlchemyModelViewSet <EOL> class APIModelBuilder ( object ) : <EOL> def __init__ ( self , <EOL> models , <EOL> base_managers , <EOL> base_viewsets = None , <EOL> * args , ** kwargs ) : <EOL> self . models = models <EOL> if not isinstance ( base_managers , ( tuple , list ) ) : <EOL> base_managers = [ base_managers ] <EOL> if not isinstance ( base_managers , tuple ) : <EOL> base_managers = tuple ( base_managers ) <EOL> if base_viewsets is None : <EOL> base_viewsets = ( AlchemyModelViewSet , ) <EOL> self . base_managers = base_managers <EOL> self . base_viewsets = base_viewsets <EOL> @ property <EOL> def urls ( self ) : <EOL> router = ReadOnlyRouter ( ) <EOL> for model in self . models : <EOL> manager = type ( <EOL> str ( '<STR_LIT>' . format ( model . __name__ ) ) , <EOL> self . base_managers + ( AlchemyModelManager , ) , <EOL> { <EOL> '<STR_LIT>' : model , <EOL> } <EOL> ) <EOL> viewset = type ( <EOL> str ( '<STR_LIT>' . format ( model . __name__ ) ) , <EOL> self . base_viewsets , <EOL> { <EOL> '<STR_LIT>' : manager , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> } <EOL> ) <EOL> router . register ( '<STR_LIT>' + model . __name__ . lower ( ) + '<STR_LIT:s>' , <EOL> viewset , <EOL> base_name = model . __name__ ) <EOL> return router . urls </s>
