Merge "Use instanceof instead of type"

This commit is contained in:
Jenkins 2016-02-23 08:50:24 +00:00 committed by Gerrit Code Review
commit 02e5b6f41d
3 changed files with 6 additions and 6 deletions
openstackclient

@ -243,14 +243,14 @@ class BaseAPI(KeystoneSession):
def getlist(kw): def getlist(kw):
"""Do list call, unwrap resource dict if present""" """Do list call, unwrap resource dict if present"""
ret = self.list(path, **kw) ret = self.list(path, **kw)
if type(ret) == dict and resource in ret: if isinstance(ret, dict) and resource in ret:
ret = ret[resource] ret = ret[resource]
return ret return ret
# Search by attribute # Search by attribute
kwargs = {attr: value} kwargs = {attr: value}
data = getlist(kwargs) data = getlist(kwargs)
if type(data) == dict: if isinstance(data, dict):
return data return data
if len(data) == 1: if len(data) == 1:
return data[0] return data[0]
@ -283,7 +283,7 @@ class BaseAPI(KeystoneSession):
""" """
items = self.list(path) items = self.list(path)
if type(items) == dict: if isinstance(items, dict):
# strip off the enclosing dict # strip off the enclosing dict
key = list(items.keys())[0] key = list(items.keys())[0]
items = items[key] items = items[key]

@ -61,7 +61,7 @@ def simple_filter(
# Searching data fields # Searching data fields
search_value = d[attr] search_value = d[attr]
elif (property_field and property_field in d and elif (property_field and property_field in d and
type(d[property_field]) is dict): isinstance(d[property_field], dict)):
# Searching a properties field - do this separately because # Searching a properties field - do this separately because
# we don't want to fail over to checking the fields if a # we don't want to fail over to checking the fields if a
# property name is given. # property name is given.

@ -317,7 +317,7 @@ class TestShellOptions(TestShell):
if not test_opts[opt][1]: if not test_opts[opt][1]:
continue continue
key = opt2attr(opt) key = opt2attr(opt)
if type(test_opts[opt][0]) is str: if isinstance(test_opts[opt][0], str):
cmd = opt + " " + test_opts[opt][0] cmd = opt + " " + test_opts[opt][0]
else: else:
cmd = opt cmd = opt
@ -331,7 +331,7 @@ class TestShellOptions(TestShell):
if not test_opts[opt][1]: if not test_opts[opt][1]:
continue continue
key = opt2attr(opt) key = opt2attr(opt)
if type(test_opts[opt][0]) is str: if isinstance(test_opts[opt][0], str):
cmd = opt + " " + test_opts[opt][0] cmd = opt + " " + test_opts[opt][0]
else: else:
cmd = opt cmd = opt