From 4e44bbcf4bca14060fb2c9ba704a16527e675c24 Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Tue, 26 Sep 2017 13:15:57 +0800 Subject: [PATCH] Fix vfc-catalog/swagger pep8 issue. Change-Id: I8d1d641fa8e259b74b5cf109b67c61985525b0cc Issue-ID: VFC-456 Signed-off-by: ying.yunlong --- lcm/samples/views.py | 12 +++--------- lcm/swagger/tests.py | 2 +- lcm/swagger/views.py | 12 +----------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/lcm/samples/views.py b/lcm/samples/views.py index 0e3c6acf..53153d0b 100644 --- a/lcm/samples/views.py +++ b/lcm/samples/views.py @@ -15,11 +15,9 @@ import logging import traceback -from rest_framework.views import APIView -from rest_framework.response import Response from rest_framework import status -from lcm.pub.database import models - +from rest_framework.response import Response +from rest_framework.views import APIView logger = logging.getLogger(__name__) @@ -32,6 +30,7 @@ class SampleList(APIView): logger.debug("get") return Response({"status": "active"}) + class TablesList(APIView): def delete(self, request, modelName): logger.debug("Start delete model %s", modelName) @@ -47,7 +46,6 @@ class TablesList(APIView): status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(data={}, status=status.HTTP_204_NO_CONTENT) - def get(self, request, modelName): logger.debug("Get model %s", modelName) count = 0 @@ -59,7 +57,3 @@ class TablesList(APIView): return Response(data={"error": "failed"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(data={"count": count}, status=status.HTTP_200_OK) - - - - diff --git a/lcm/swagger/tests.py b/lcm/swagger/tests.py index 54551faf..4f2e6522 100644 --- a/lcm/swagger/tests.py +++ b/lcm/swagger/tests.py @@ -10,7 +10,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import unittest -import json + from django.test import Client from rest_framework import status diff --git a/lcm/swagger/views.py b/lcm/swagger/views.py index fdef8aed..5034905c 100644 --- a/lcm/swagger/views.py +++ b/lcm/swagger/views.py @@ -14,20 +14,16 @@ import json import logging import os -import traceback -from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView - logger = logging.getLogger(__name__) class SwaggerJsonView(APIView): def get(self, request): - json_file = os.path.join(os.path.dirname(__file__), 'vfc.nslcm.swagger.json') f = open(json_file) json_data = json.JSONDecoder().decode(f.read()) @@ -49,7 +45,6 @@ class SwaggerJsonView(APIView): json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'vfc.sfclcm.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) @@ -58,18 +53,13 @@ class SwaggerJsonView(APIView): json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'vfc.others.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() - json_data_jobtemp=json_data["paths"]["/jobs/{jobId}"] + json_data_jobtemp = json_data["paths"]["/jobs/{jobId}"] json_data["paths"].update(json_data_temp["paths"]) json_data["paths"]["/jobs/{jobId}"].update(json_data_jobtemp) json_data["definitions"].update(json_data_temp["definitions"]) - return Response(json_data) - - - -- 2.16.6