Remove redundant parentheses in conditional statements
It's not pythonic to use parentheses in conditional statements which can fit into single line. Following patch removes redundant parentheses from the code. Change-Id: I01544931cc49b250b8224a593c64d7b59b576799
This commit is contained in:
parent
713eaf1031
commit
58667c1bc4
|
@ -124,8 +124,7 @@ class ImageMemberRepoProxy(glance.domain.proxy.Repo):
|
|||
|
||||
def get(self, member_id):
|
||||
if (self.context.is_admin or
|
||||
self.context.owner == self.image.owner or
|
||||
self.context.owner == member_id):
|
||||
self.context.owner in (self.image.owner, member_id)):
|
||||
member = self.member_repo.get(member_id)
|
||||
return proxy_member(self.context, member)
|
||||
else:
|
||||
|
|
|
@ -293,7 +293,7 @@ class ImagesController(object):
|
|||
except Exception as e:
|
||||
raise webob.exc.HTTPInternalServerError(
|
||||
explanation=utils.exception_to_str(e))
|
||||
if (len(image.locations) == 0) and (image.status == 'active'):
|
||||
if len(image.locations) == 0 and image.status == 'active':
|
||||
image.status = 'queued'
|
||||
|
||||
|
||||
|
|
|
@ -380,8 +380,7 @@ def main():
|
|||
pid_file = get_pid_file(server, CONF.pid_file)
|
||||
do_start('Restart', pid_file, server, CONF.server.args)
|
||||
|
||||
if (CONF.server.command == 'reload' or
|
||||
CONF.server.command == 'force-reload'):
|
||||
if CONF.server.command in ('reload', 'force-reload'):
|
||||
for server in CONF.server.servers:
|
||||
do_stop(server, CONF.server.args, graceful=True)
|
||||
pid_file = get_pid_file(server, CONF.pid_file)
|
||||
|
|
|
@ -494,7 +494,7 @@ def image_member_create(context, values):
|
|||
def image_member_update(context, member_id, values):
|
||||
global DATA
|
||||
for member in DATA['members']:
|
||||
if (member['id'] == member_id):
|
||||
if member['id'] == member_id:
|
||||
member.update(values)
|
||||
member['updated_at'] = timeutils.utcnow()
|
||||
return copy.deepcopy(member)
|
||||
|
@ -506,7 +506,7 @@ def image_member_update(context, member_id, values):
|
|||
def image_member_delete(context, member_id):
|
||||
global DATA
|
||||
for i, member in enumerate(DATA['members']):
|
||||
if (member['id'] == member_id):
|
||||
if member['id'] == member_id:
|
||||
del DATA['members'][i]
|
||||
break
|
||||
else:
|
||||
|
@ -541,7 +541,7 @@ def image_location_update(context, image_id, location):
|
|||
|
||||
updated = False
|
||||
for loc in DATA['locations']:
|
||||
if (loc['id'] == loc_id and loc['image_id'] == image_id):
|
||||
if loc['id'] == loc_id and loc['image_id'] == image_id:
|
||||
loc.update({"value": location['url'],
|
||||
"meta_data": location['metadata'],
|
||||
"status": location['status'],
|
||||
|
@ -568,7 +568,7 @@ def image_location_delete(context, image_id, location_id, status,
|
|||
|
||||
deleted = False
|
||||
for loc in DATA['locations']:
|
||||
if (loc['id'] == location_id and loc['image_id'] == image_id):
|
||||
if loc['id'] == location_id and loc['image_id'] == image_id:
|
||||
deleted = True
|
||||
delete_time = delete_time or timeutils.utcnow()
|
||||
loc.update({"deleted": deleted,
|
||||
|
@ -1694,8 +1694,7 @@ def metadef_tag_get(context, namespace_name, name):
|
|||
_check_namespace_visibility(context, namespace, namespace_name)
|
||||
|
||||
for tag in DATA['metadef_tags']:
|
||||
if (tag['namespace_id'] == namespace['id'] and
|
||||
tag['name'] == name):
|
||||
if tag['namespace_id'] == namespace['id'] and tag['name'] == name:
|
||||
return tag
|
||||
else:
|
||||
msg = ("The metadata definition tag with name=%(name)s"
|
||||
|
@ -1713,8 +1712,7 @@ def metadef_tag_get_by_id(context, namespace_name, id):
|
|||
_check_namespace_visibility(context, namespace, namespace_name)
|
||||
|
||||
for tag in DATA['metadef_tags']:
|
||||
if (tag['namespace_id'] == namespace['id'] and
|
||||
tag['id'] == id):
|
||||
if tag['namespace_id'] == namespace['id'] and tag['id'] == id:
|
||||
return tag
|
||||
else:
|
||||
msg = (_("Metadata definition tag not found for id=%s") % id)
|
||||
|
@ -1752,8 +1750,7 @@ def metadef_tag_create(context, namespace_name, values):
|
|||
namespace = metadef_namespace_get(context, namespace_name)
|
||||
|
||||
for tag in DATA['metadef_tags']:
|
||||
if (tag['name'] == tag_name and
|
||||
tag['namespace_id'] == namespace['id']):
|
||||
if tag['name'] == tag_name and tag['namespace_id'] == namespace['id']:
|
||||
msg = ("A metadata definition tag with name=%(name)s"
|
||||
" in namespace=%(namespace_name)s already exists."
|
||||
% {'name': tag_name, 'namespace_name': namespace_name})
|
||||
|
|
|
@ -1306,8 +1306,7 @@ def task_get_all(context, filters=None, marker=None, limit=None,
|
|||
session = get_session()
|
||||
query = session.query(models.Task)
|
||||
|
||||
if (not (context.is_admin or admin_as_user == True)
|
||||
and context.owner is not None):
|
||||
if not (context.is_admin or admin_as_user) and context.owner is not None:
|
||||
query = query.filter(models.Task.owner == context.owner)
|
||||
|
||||
showing_deleted = False
|
||||
|
|
|
@ -29,8 +29,7 @@ ORIGINAL_KEYNAME_RE = re.compile('image_members_image_id.*_key')
|
|||
def upgrade(migrate_engine):
|
||||
image_members = _get_image_members_table(migrate_engine)
|
||||
|
||||
if (migrate_engine.name == 'mysql' or
|
||||
migrate_engine.name == 'postgresql'):
|
||||
if migrate_engine.name in ('mysql', 'postgresql'):
|
||||
try:
|
||||
UniqueConstraint('image_id',
|
||||
name=_get_original_keyname(migrate_engine.name),
|
||||
|
@ -49,8 +48,7 @@ def upgrade(migrate_engine):
|
|||
def downgrade(migrate_engine):
|
||||
image_members = _get_image_members_table(migrate_engine)
|
||||
|
||||
if (migrate_engine.name == 'mysql' or
|
||||
migrate_engine.name == 'postgresql'):
|
||||
if migrate_engine.name in ('mysql', 'postgresql'):
|
||||
_sanitize(migrate_engine, image_members)
|
||||
UniqueConstraint('image_id',
|
||||
name=NEW_KEYNAME,
|
||||
|
|
|
@ -116,7 +116,7 @@ def _count_duplicated_locations(locations, new):
|
|||
|
||||
ret = 0
|
||||
for loc in locations:
|
||||
if (loc['url'] == new['url'] and loc['metadata'] == new['metadata']):
|
||||
if loc['url'] == new['url'] and loc['metadata'] == new['metadata']:
|
||||
ret += 1
|
||||
return ret
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ class TestScrubDBQueue(test_utils.BaseTestCase):
|
|||
class ImagePager(object):
|
||||
def __init__(self, images, page_size=0):
|
||||
image_count = len(images)
|
||||
if (page_size == 0) or (page_size > image_count):
|
||||
if page_size == 0 or page_size > image_count:
|
||||
page_size = image_count
|
||||
self.image_batches = []
|
||||
start = 0
|
||||
|
|
Loading…
Reference in New Issue