diff options
| author | lzyeval <lzyeval@gmail.com> | 2011-12-31 12:23:56 +0800 |
|---|---|---|
| committer | lzyeval <lzyeval@gmail.com> | 2012-01-04 07:32:13 +0800 |
| commit | 88ccade9d5700db881f2ffc53e4a48a76e92c2db (patch) | |
| tree | f8da941637a68a89705ac7e717992ac8b7d44fc7 /nova/api | |
| parent | 6f0ef4240fc42f3bf4e7b59cd83997edddb3c985 (diff) | |
| download | nova-88ccade9d5700db881f2ffc53e4a48a76e92c2db.tar.gz nova-88ccade9d5700db881f2ffc53e4a48a76e92c2db.tar.xz nova-88ccade9d5700db881f2ffc53e4a48a76e92c2db.zip | |
PEP8 type comparison cleanup
Fixes bug #910295
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'.
"== None", "== True", "== False", and "!= None" comparisons in sqlalchemy's
where(), or_(), filter(), and_(), and select() functions should not be changed.
Incorrect comparisons or evaluations in comments were not changed.
Change-Id: I087f0883bf115b5fe714ccfda86a794b9b2a87f7
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/apirequest.py | 2 | ||||
| -rw-r--r-- | nova/api/ec2/cloud.py | 6 | ||||
| -rw-r--r-- | nova/api/openstack/v2/contrib/flavorextraspecs.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/v2/contrib/volumetypes.py | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/nova/api/ec2/apirequest.py b/nova/api/ec2/apirequest.py index dd1692d50..f40be6e2a 100644 --- a/nova/api/ec2/apirequest.py +++ b/nova/api/ec2/apirequest.py @@ -99,7 +99,7 @@ class APIRequest(object): request_id_el = xml.createElement('requestId') request_id_el.appendChild(xml.createTextNode(request_id)) response_el.appendChild(request_id_el) - if(response_data == True): + if response_data is True: self._render_dict(xml, response_el, {'return': 'true'}) else: self._render_dict(xml, response_el, response_data) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index dccb358aa..09324bb3c 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -884,7 +884,7 @@ class CloudController(object): 'volumeId': v['volumeId']}] else: v['attachmentSet'] = [{}] - if volume.get('snapshot_id') != None: + if volume.get('snapshot_id') is not None: v['snapshotId'] = ec2utils.id_to_ec2_snap_id(volume['snapshot_id']) else: v['snapshotId'] = None @@ -895,7 +895,7 @@ class CloudController(object): def create_volume(self, context, **kwargs): size = kwargs.get('size') - if kwargs.get('snapshot_id') != None: + if kwargs.get('snapshot_id') is not None: snapshot_id = ec2utils.ec2_id_to_id(kwargs['snapshot_id']) LOG.audit(_("Create volume from snapshot %s"), snapshot_id, context=context) @@ -1425,7 +1425,7 @@ class CloudController(object): 'ari': 'ramdisk', 'ami': 'machine'} i['imageType'] = display_mapping.get(image_type) - i['isPublic'] = image.get('is_public') == True + i['isPublic'] = not not image.get('is_public') i['architecture'] = image['properties'].get('architecture') properties = image['properties'] diff --git a/nova/api/openstack/v2/contrib/flavorextraspecs.py b/nova/api/openstack/v2/contrib/flavorextraspecs.py index 1fbd74138..b7013a32d 100644 --- a/nova/api/openstack/v2/contrib/flavorextraspecs.py +++ b/nova/api/openstack/v2/contrib/flavorextraspecs.py @@ -37,7 +37,7 @@ class FlavorExtraSpecsController(object): return dict(extra_specs=specs_dict) def _check_body(self, body): - if body == None or body == "": + if body is None or body == "": expl = _('No Request Body') raise exc.HTTPBadRequest(explanation=expl) diff --git a/nova/api/openstack/v2/contrib/volumetypes.py b/nova/api/openstack/v2/contrib/volumetypes.py index a963fdb1f..6906b522f 100644 --- a/nova/api/openstack/v2/contrib/volumetypes.py +++ b/nova/api/openstack/v2/contrib/volumetypes.py @@ -132,7 +132,7 @@ class VolumeTypeExtraSpecsController(object): return dict(extra_specs=specs_dict) def _check_body(self, body): - if body == None or body == "": + if body is None or body == "": expl = _('No Request Body') raise exc.HTTPBadRequest(explanation=expl) |
