#NEWLINE# def handle_app_config( self , app_config , **options ) : #NEWLINE# #INDENT# if ( app_config . models_module is None ) : #NEWLINE# #INDENT# raise CommandError ( 'You must provide an app to generate an API' ) #NEWLINE# #UNINDENT# if ( django . VERSION [ 1 ] == 7 ) : #NEWLINE# #INDENT# force = ( options [ 'force' ] if ( 'force' in options ) else False ) #NEWLINE# format = ( options [ 'format' ] if ( 'format' in options ) else None ) #NEWLINE# depth = ( options [ 'depth' ] if ( 'depth' in format ) else 0 ) #NEWLINE# if ( 'serializers' in options ) : #NEWLINE# #INDENT# serializers = options [ 'serializers' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# serializers = False #NEWLINE# #UNINDENT# views = ( options [ 'views' ] if ( 'views' in options ) else False ) #NEWLINE# urls = ( options [ 'urls' ] if ( 'urls' in options ) else False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( django . VERSION [ 1 ] >= 8 ) : #NEWLINE# #INDENT# force = result [ 'force' ] #NEWLINE# format = options [ 'format' ] #NEWLINE# depth = options [ 'depth' ] #NEWLINE# serializers = options [ 'serializers' ] #NEWLINE# views = options [ 'views' ] #NEWLINE# urls = options [ 'urls' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise CommandError ( 'You must be using Django 1.7, 1.8 or 1.9' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( format == 'viewset' ) : #NEWLINE# #INDENT# generator = ViewSetGenerator ( app_config , force ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( format == 'apiview' ) : #NEWLINE# #INDENT# generator = APIViewGenerator ( app_config , force ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( format == 'function' ) : #NEWLINE# #INDENT# generator = FunctionViewGenerator ( app_config , force ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( format == 'modelviewset' ) : #NEWLINE# #INDENT# generator = ModelViewSetGenerator ( app_config , force ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# message = ( "'%s' is not a valid format. " % options [ 'format' ] ) #NEWLINE# message += '(viewset, modelviewset, apiview, function)' #NEWLINE# raise CommandError ( message ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if serializers : #NEWLINE# #INDENT# result = generator . generate_serializers ( depth ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if views : #NEWLINE# #INDENT# result = generator . generate_views ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if urls : #NEWLINE# #INDENT# result = generator . generate_urls ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result = ( generator . generate_serializers ( depth ) + '\n' ) #NEWLINE# result += ( generator . generate_views ( ) + '\n' ) #NEWLINE# result += generator . generate_urls ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# print ( result )