From 0504354233e2f856b8275036f1e58840aecf9a11 Mon Sep 17 00:00:00 2001 From: bhagyashris Date: Fri, 26 Aug 2016 13:19:43 +0530 Subject: [PATCH] Replace functions 'Dict.get' and 'del' with 'Dict.pop' Refactoring code: Making dicts to use single instruction: pop() rather than two instructions: get() and del, giving the codes a format that carries through. TrivialFix Change-Id: Ie404888ccf257978e0ac491165926dfde9a3e6d6 --- cinderclient/client.py | 3 +-- cinderclient/openstack/common/apiclient/client.py | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/cinderclient/client.py b/cinderclient/client.py index 0f9531125..7d0356352 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -307,8 +307,7 @@ class HTTPClient(object): if 'body' in kwargs: kwargs['headers']['Content-Type'] = 'application/json' - kwargs['data'] = json.dumps(kwargs['body']) - del kwargs['body'] + kwargs['data'] = json.dumps(kwargs.pop('body')) api_versions.update_headers(kwargs["headers"], self.api_version) if self.timeout: diff --git a/cinderclient/openstack/common/apiclient/client.py b/cinderclient/openstack/common/apiclient/client.py index ec9c6d5aa..3741df913 100644 --- a/cinderclient/openstack/common/apiclient/client.py +++ b/cinderclient/openstack/common/apiclient/client.py @@ -144,11 +144,7 @@ class HTTPClient(object): def serialize(self, kwargs): if kwargs.get('json') is not None: kwargs['headers']['Content-Type'] = 'application/json' - kwargs['data'] = json.dumps(kwargs['json']) - try: - del kwargs['json'] - except KeyError: - pass + kwargs['data'] = json.dumps(kwargs.pop('json')) def get_timings(self): return self.times