From 88ccade9d5700db881f2ffc53e4a48a76e92c2db Mon Sep 17 00:00:00 2001 From: lzyeval Date: Sat, 31 Dec 2011 12:23:56 +0800 Subject: 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 --- nova/virt/images.py | 2 +- nova/virt/xenapi/volumeops.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/images.py b/nova/virt/images.py index e088a92b3..b884e5124 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -69,7 +69,7 @@ def fetch_to_raw(context, image_href, path, user_id, project_id): data = _qemu_img_info(path_tmp) fmt = data.get("file format", None) - if fmt == None: + if fmt is None: os.unlink(path_tmp) raise exception.ImageUnacceptable( reason=_("'qemu-img info' parsing failed."), image_id=image_href) diff --git a/nova/virt/xenapi/volumeops.py b/nova/virt/xenapi/volumeops.py index f9ba17fe6..0bce133ef 100644 --- a/nova/virt/xenapi/volumeops.py +++ b/nova/virt/xenapi/volumeops.py @@ -61,7 +61,7 @@ class VolumeOps(object): def delete_volume_for_sm(self, vdi_uuid): vdi_ref = self._session.call_xenapi("VDI.get_by_uuid", vdi_uuid) - if vdi_ref == None: + if vdi_ref is None: raise exception.Error(_('Could not find VDI ref')) try: @@ -73,10 +73,10 @@ class VolumeOps(object): def create_sr(self, label, params): LOG.debug(_("Creating SR %s") % label) sr_ref = VolumeHelper.create_sr(self._session, label, params) - if sr_ref == None: + if sr_ref is None: raise exception.Error(_('Could not create SR')) sr_rec = self._session.call_xenapi("SR.get_record", sr_ref) - if sr_rec == None: + if sr_rec is None: raise exception.Error(_('Could not retrieve SR record')) return sr_rec['uuid'] @@ -89,7 +89,7 @@ class VolumeOps(object): return sr_ref sr_ref = VolumeHelper.introduce_sr(self._session, sr_uuid, label, params) - if sr_ref == None: + if sr_ref is None: raise exception.Error(_('Could not introduce SR')) return sr_ref @@ -103,7 +103,7 @@ class VolumeOps(object): # Checks if sr has been introduced def forget_sr(self, sr_uuid): sr_ref = VolumeHelper.find_sr_by_uuid(self._session, sr_uuid) - if sr_ref == None: + if sr_ref is None: LOG.INFO(_('SR %s not found in the xapi database') % sr_uuid) return try: -- cgit