From 4ff27703d077fc83bb715060a774faf4a15e9736 Mon Sep 17 00:00:00 2001 From: lzyeval Date: Wed, 4 Jan 2012 09:54:39 +0800 Subject: [PATCH] PEP8 python-novaclient cleanup Fixes bug #911552 The None, True, and False values are singletons. All variable *comparisons* to singletons should use 'is' or 'is not'. All variable *evaluations* to boolean should use 'if' or 'if not'. All Object type comparisons should use isinstance() instead of comparing types directly Change-Id: Ia5571e58e2662c652f0e996d8c1a1acb4531623d --- AUTHORS | 1 + novaclient/base.py | 2 +- novaclient/client.py | 2 +- novaclient/v1_1/quotas.py | 2 +- novaclient/v1_1/shell.py | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 7c65b0cae..3006e7c6c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -37,3 +37,4 @@ Robie Basak Sandy Walsh Unmesh Gurjar William Wolf +Zhongyue Luo diff --git a/novaclient/base.py b/novaclient/base.py index d1cbf8a5f..94e825087 100644 --- a/novaclient/base.py +++ b/novaclient/base.py @@ -74,7 +74,7 @@ class Manager(utils.HookableMixin): data = body[response_key] # NOTE(ja): keystone returns values as list as {'values': [ ... ]} # unlike other services which just return the list... - if type(data) is dict: + if isinstance(data, dict): try: data = data['values'] except KeyError: diff --git a/novaclient/client.py b/novaclient/client.py index b34a2ae11..a8710d10b 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -192,7 +192,7 @@ class HTTPClient(httplib2.Http): magic_tuple = urlparse.urlsplit(self.auth_url) scheme, netloc, path, query, frag = magic_tuple port = magic_tuple.port - if port == None: + if port is None: port = 80 path_parts = path.split('/') for part in path_parts: diff --git a/novaclient/v1_1/quotas.py b/novaclient/v1_1/quotas.py index 461540b11..e2b0d1441 100644 --- a/novaclient/v1_1/quotas.py +++ b/novaclient/v1_1/quotas.py @@ -51,7 +51,7 @@ class QuotaSetManager(base.ManagerWithFind): 'cores': cores}} for key in body['quota_set'].keys(): - if body['quota_set'][key] == None: + if body['quota_set'][key] is None: body['quota_set'].pop(key) self._update('/os-quota-sets/%s' % (tenant_id), body) diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index ac9038a7e..cc6b50ad1 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -503,7 +503,7 @@ def do_rebuild(cs, args): server = _find_server(cs, args.server) image = _find_image(cs, args.image) - if args.rebuild_password != False: + if args.rebuild_password is not False: _password = args.rebuild_password else: _password = None @@ -1012,7 +1012,7 @@ def _print_secgroup_rules(rules): elif k == 'group': k = 'source_group' v = v.get('name') - if v == None: + if v is None: v = '' setattr(self, k, v)