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
This commit is contained in:
@@ -1605,7 +1605,7 @@ class VsaDriveTypeCommands(object):
|
||||
if name is not None:
|
||||
search_opts['extra_specs']['name'] = name
|
||||
|
||||
if all == False:
|
||||
if not all:
|
||||
search_opts['extra_specs']['visible'] = '1'
|
||||
|
||||
drives = volume_types.get_all_types(self.context,
|
||||
@@ -1973,7 +1973,7 @@ class StorageManagerCommands(object):
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
try:
|
||||
if flavor == None:
|
||||
if flavor is None:
|
||||
flavors = db.sm_flavor_get_all(ctxt)
|
||||
else:
|
||||
flavors = db.sm_flavor_get(ctxt, flavor)
|
||||
@@ -2015,7 +2015,7 @@ class StorageManagerCommands(object):
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
try:
|
||||
if backend_conf_id == None:
|
||||
if backend_conf_id is None:
|
||||
backends = db.sm_backend_conf_get_all(ctxt)
|
||||
else:
|
||||
backends = db.sm_backend_conf_get(ctxt, backend_conf_id)
|
||||
@@ -2075,7 +2075,7 @@ class StorageManagerCommands(object):
|
||||
print '(WARNING: Creating will destroy all data on backend!!!)'
|
||||
c = raw_input('Proceed? (y/n) ')
|
||||
if c == 'y' or c == 'Y':
|
||||
if flavor_label == None:
|
||||
if flavor_label is None:
|
||||
print "error: backend needs to be associated with flavor"
|
||||
sys.exit(2)
|
||||
|
||||
|
@@ -821,7 +821,7 @@ class ConfigOpts(object):
|
||||
:return: False if the opt was already register, True otherwise
|
||||
:raises: DuplicateOptError, ArgsAlreadyParsedError
|
||||
"""
|
||||
if self._args != None:
|
||||
if self._args is not None:
|
||||
raise ArgsAlreadyParsedError("cannot register CLI option")
|
||||
|
||||
if not self.register_opt(opt, group):
|
||||
|
@@ -130,8 +130,7 @@ class VsaScheduler(simple.SimpleScheduler):
|
||||
return filtered_hosts
|
||||
|
||||
def _allowed_to_use_host(self, host, selected_hosts, unique):
|
||||
if unique == False or \
|
||||
host not in [item[0] for item in selected_hosts]:
|
||||
if not unique or host not in [item[0] for item in selected_hosts]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@@ -236,11 +236,11 @@ class DistributedSchedulerTestCase(test.TestCase):
|
||||
for weighted_host in weighted_hosts:
|
||||
# We set this up so remote hosts have even weights ...
|
||||
if int(weighted_host.weight) % 2 == 0:
|
||||
self.assertTrue(weighted_host.zone != None)
|
||||
self.assertTrue(weighted_host.host == None)
|
||||
self.assertTrue(weighted_host.zone is not None)
|
||||
self.assertTrue(weighted_host.host is None)
|
||||
else:
|
||||
self.assertTrue(weighted_host.host != None)
|
||||
self.assertTrue(weighted_host.zone == None)
|
||||
self.assertTrue(weighted_host.host is not None)
|
||||
self.assertTrue(weighted_host.zone is None)
|
||||
|
||||
def test_schedule_local_zone(self):
|
||||
"""Test to make sure _schedule makes no call out to zones if
|
||||
@@ -270,8 +270,8 @@ class DistributedSchedulerTestCase(test.TestCase):
|
||||
self.assertEquals(len(weighted_hosts), 10)
|
||||
for weighted_host in weighted_hosts:
|
||||
# There should be no remote hosts
|
||||
self.assertTrue(weighted_host.host != None)
|
||||
self.assertTrue(weighted_host.zone == None)
|
||||
self.assertTrue(weighted_host.host is not None)
|
||||
self.assertTrue(weighted_host.zone is None)
|
||||
|
||||
def test_decrypt_blob(self):
|
||||
"""Test that the decrypt method works."""
|
||||
|
@@ -68,10 +68,10 @@ class API(base.Base):
|
||||
super(API, self).__init__(**kwargs)
|
||||
|
||||
def _check_volume_type_correctness(self, vol_type):
|
||||
if vol_type.get('extra_specs') == None or\
|
||||
if vol_type.get('extra_specs') is None or\
|
||||
vol_type['extra_specs'].get('type') != 'vsa_drive' or\
|
||||
vol_type['extra_specs'].get('drive_type') == None or\
|
||||
vol_type['extra_specs'].get('drive_size') == None:
|
||||
vol_type['extra_specs'].get('drive_type') is None or\
|
||||
vol_type['extra_specs'].get('drive_size') is None:
|
||||
|
||||
raise exception.ApiError(_("Invalid drive type %s")
|
||||
% vol_type['name'])
|
||||
@@ -162,7 +162,7 @@ class API(base.Base):
|
||||
if storage is None:
|
||||
storage = []
|
||||
|
||||
if shared is None or shared == 'False' or shared == False:
|
||||
if not shared or shared == 'False':
|
||||
shared = False
|
||||
else:
|
||||
shared = True
|
||||
|
Reference in New Issue
Block a user