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):
|
def get(self, member_id):
|
||||||
if (self.context.is_admin or
|
if (self.context.is_admin or
|
||||||
self.context.owner == self.image.owner or
|
self.context.owner in (self.image.owner, member_id)):
|
||||||
self.context.owner == member_id):
|
|
||||||
member = self.member_repo.get(member_id)
|
member = self.member_repo.get(member_id)
|
||||||
return proxy_member(self.context, member)
|
return proxy_member(self.context, member)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -293,7 +293,7 @@ class ImagesController(object):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise webob.exc.HTTPInternalServerError(
|
raise webob.exc.HTTPInternalServerError(
|
||||||
explanation=utils.exception_to_str(e))
|
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'
|
image.status = 'queued'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -380,8 +380,7 @@ def main():
|
||||||
pid_file = get_pid_file(server, CONF.pid_file)
|
pid_file = get_pid_file(server, CONF.pid_file)
|
||||||
do_start('Restart', pid_file, server, CONF.server.args)
|
do_start('Restart', pid_file, server, CONF.server.args)
|
||||||
|
|
||||||
if (CONF.server.command == 'reload' or
|
if CONF.server.command in ('reload', 'force-reload'):
|
||||||
CONF.server.command == 'force-reload'):
|
|
||||||
for server in CONF.server.servers:
|
for server in CONF.server.servers:
|
||||||
do_stop(server, CONF.server.args, graceful=True)
|
do_stop(server, CONF.server.args, graceful=True)
|
||||||
pid_file = get_pid_file(server, CONF.pid_file)
|
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):
|
def image_member_update(context, member_id, values):
|
||||||
global DATA
|
global DATA
|
||||||
for member in DATA['members']:
|
for member in DATA['members']:
|
||||||
if (member['id'] == member_id):
|
if member['id'] == member_id:
|
||||||
member.update(values)
|
member.update(values)
|
||||||
member['updated_at'] = timeutils.utcnow()
|
member['updated_at'] = timeutils.utcnow()
|
||||||
return copy.deepcopy(member)
|
return copy.deepcopy(member)
|
||||||
|
@ -506,7 +506,7 @@ def image_member_update(context, member_id, values):
|
||||||
def image_member_delete(context, member_id):
|
def image_member_delete(context, member_id):
|
||||||
global DATA
|
global DATA
|
||||||
for i, member in enumerate(DATA['members']):
|
for i, member in enumerate(DATA['members']):
|
||||||
if (member['id'] == member_id):
|
if member['id'] == member_id:
|
||||||
del DATA['members'][i]
|
del DATA['members'][i]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -541,7 +541,7 @@ def image_location_update(context, image_id, location):
|
||||||
|
|
||||||
updated = False
|
updated = False
|
||||||
for loc in DATA['locations']:
|
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'],
|
loc.update({"value": location['url'],
|
||||||
"meta_data": location['metadata'],
|
"meta_data": location['metadata'],
|
||||||
"status": location['status'],
|
"status": location['status'],
|
||||||
|
@ -568,7 +568,7 @@ def image_location_delete(context, image_id, location_id, status,
|
||||||
|
|
||||||
deleted = False
|
deleted = False
|
||||||
for loc in DATA['locations']:
|
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
|
deleted = True
|
||||||
delete_time = delete_time or timeutils.utcnow()
|
delete_time = delete_time or timeutils.utcnow()
|
||||||
loc.update({"deleted": deleted,
|
loc.update({"deleted": deleted,
|
||||||
|
@ -1694,8 +1694,7 @@ def metadef_tag_get(context, namespace_name, name):
|
||||||
_check_namespace_visibility(context, namespace, namespace_name)
|
_check_namespace_visibility(context, namespace, namespace_name)
|
||||||
|
|
||||||
for tag in DATA['metadef_tags']:
|
for tag in DATA['metadef_tags']:
|
||||||
if (tag['namespace_id'] == namespace['id'] and
|
if tag['namespace_id'] == namespace['id'] and tag['name'] == name:
|
||||||
tag['name'] == name):
|
|
||||||
return tag
|
return tag
|
||||||
else:
|
else:
|
||||||
msg = ("The metadata definition tag with name=%(name)s"
|
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)
|
_check_namespace_visibility(context, namespace, namespace_name)
|
||||||
|
|
||||||
for tag in DATA['metadef_tags']:
|
for tag in DATA['metadef_tags']:
|
||||||
if (tag['namespace_id'] == namespace['id'] and
|
if tag['namespace_id'] == namespace['id'] and tag['id'] == id:
|
||||||
tag['id'] == id):
|
|
||||||
return tag
|
return tag
|
||||||
else:
|
else:
|
||||||
msg = (_("Metadata definition tag not found for id=%s") % id)
|
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)
|
namespace = metadef_namespace_get(context, namespace_name)
|
||||||
|
|
||||||
for tag in DATA['metadef_tags']:
|
for tag in DATA['metadef_tags']:
|
||||||
if (tag['name'] == tag_name and
|
if tag['name'] == tag_name and tag['namespace_id'] == namespace['id']:
|
||||||
tag['namespace_id'] == namespace['id']):
|
|
||||||
msg = ("A metadata definition tag with name=%(name)s"
|
msg = ("A metadata definition tag with name=%(name)s"
|
||||||
" in namespace=%(namespace_name)s already exists."
|
" in namespace=%(namespace_name)s already exists."
|
||||||
% {'name': tag_name, 'namespace_name': namespace_name})
|
% {'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()
|
session = get_session()
|
||||||
query = session.query(models.Task)
|
query = session.query(models.Task)
|
||||||
|
|
||||||
if (not (context.is_admin or admin_as_user == True)
|
if not (context.is_admin or admin_as_user) and context.owner is not None:
|
||||||
and context.owner is not None):
|
|
||||||
query = query.filter(models.Task.owner == context.owner)
|
query = query.filter(models.Task.owner == context.owner)
|
||||||
|
|
||||||
showing_deleted = False
|
showing_deleted = False
|
||||||
|
|
|
@ -29,8 +29,7 @@ ORIGINAL_KEYNAME_RE = re.compile('image_members_image_id.*_key')
|
||||||
def upgrade(migrate_engine):
|
def upgrade(migrate_engine):
|
||||||
image_members = _get_image_members_table(migrate_engine)
|
image_members = _get_image_members_table(migrate_engine)
|
||||||
|
|
||||||
if (migrate_engine.name == 'mysql' or
|
if migrate_engine.name in ('mysql', 'postgresql'):
|
||||||
migrate_engine.name == 'postgresql'):
|
|
||||||
try:
|
try:
|
||||||
UniqueConstraint('image_id',
|
UniqueConstraint('image_id',
|
||||||
name=_get_original_keyname(migrate_engine.name),
|
name=_get_original_keyname(migrate_engine.name),
|
||||||
|
@ -49,8 +48,7 @@ def upgrade(migrate_engine):
|
||||||
def downgrade(migrate_engine):
|
def downgrade(migrate_engine):
|
||||||
image_members = _get_image_members_table(migrate_engine)
|
image_members = _get_image_members_table(migrate_engine)
|
||||||
|
|
||||||
if (migrate_engine.name == 'mysql' or
|
if migrate_engine.name in ('mysql', 'postgresql'):
|
||||||
migrate_engine.name == 'postgresql'):
|
|
||||||
_sanitize(migrate_engine, image_members)
|
_sanitize(migrate_engine, image_members)
|
||||||
UniqueConstraint('image_id',
|
UniqueConstraint('image_id',
|
||||||
name=NEW_KEYNAME,
|
name=NEW_KEYNAME,
|
||||||
|
|
|
@ -116,7 +116,7 @@ def _count_duplicated_locations(locations, new):
|
||||||
|
|
||||||
ret = 0
|
ret = 0
|
||||||
for loc in locations:
|
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
|
ret += 1
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ class TestScrubDBQueue(test_utils.BaseTestCase):
|
||||||
class ImagePager(object):
|
class ImagePager(object):
|
||||||
def __init__(self, images, page_size=0):
|
def __init__(self, images, page_size=0):
|
||||||
image_count = len(images)
|
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
|
page_size = image_count
|
||||||
self.image_batches = []
|
self.image_batches = []
|
||||||
start = 0
|
start = 0
|
||||||
|
|
Loading…
Reference in New Issue