fixes use the fact that empty sequences are false

fixed bug #1133094

Change-Id: Ie0514be1cb0ed6741f96334f7457da331f0eebc9
This commit is contained in:
shu,xinxin 2001-02-16 03:25:45 +08:00
parent 975c5acbaa
commit 0f2d8d4d7c
8 changed files with 9 additions and 9 deletions

View File

@ -111,7 +111,7 @@ class ImagesController(object):
change_method = getattr(self, change_method_name)
change_method(req, image, change)
if len(changes) > 0:
if changes:
image_repo.save(image)
except exception.NotFound:

View File

@ -262,7 +262,7 @@ class ImageMemberRepo(object):
self.context,
self.image.image_id,
member_id)
if len(db_api_image_member) == 0:
if not db_api_image_member:
raise exception.NotFound()
except (exception.NotFound, exception.Forbidden):
raise exception.NotFound()

View File

@ -521,7 +521,7 @@ def is_image_visible(context, image, status=None):
image_id=image['id'],
member=context.owner,
status=status)
if len(members) > 0:
if members:
return True
# Private image

View File

@ -31,7 +31,7 @@ class ImageFactory(object):
raise exception.ReadonlyProperty(property=key)
def _check_unexpected(self, kwargs):
if len(kwargs) > 0:
if kwargs:
msg = 'new_image() got unexpected keywords %s'
raise TypeError(msg % kwargs.keys())
@ -84,7 +84,7 @@ class Image(object):
self.size = kwargs.pop('size', None)
self.extra_properties = kwargs.pop('extra_properties', None) or {}
self.tags = kwargs.pop('tags', None) or []
if len(kwargs) > 0:
if kwargs:
message = "__init__() got unexpected keyword argument '%s'"
raise TypeError(message % kwargs.keys()[0])

View File

@ -196,7 +196,7 @@ class Controller(object):
elif 'changes-since' not in filters:
filters['deleted'] = False
if len(properties) > 0:
if properties:
filters['properties'] = properties
return filters

View File

@ -51,7 +51,7 @@ class Schema(object):
intersecting_keys = original_keys.intersection(new_keys)
conflicting_keys = [k for k in intersecting_keys
if self.properties[k] != properties[k]]
if len(conflicting_keys) > 0:
if conflicting_keys:
props = ', '.join(conflicting_keys)
reason = _("custom properties (%(props)s) conflict "
"with base properties")

View File

@ -147,7 +147,7 @@ class StoreLocation(glance.store.location.StoreLocation):
path_parts = path.split('/')
self.key = path_parts.pop()
self.bucket = path_parts.pop()
if len(path_parts) > 0:
if path_parts:
self.s3serviceurl = '/'.join(path_parts).strip('/')
else:
reason = _("Badly formed S3 URI. Missing s3 service URL.")

View File

@ -934,7 +934,7 @@ class TestChunkReader(base.StoreClearingUnitTest):
cr = glance.store.swift.ChunkReader(infile, checksum, CHUNKSIZE)
chunk = cr.read(CHUNKSIZE)
bytes_read += len(chunk)
if len(chunk) == 0:
if not chunk:
break
self.assertEqual(1024, bytes_read)
data_file.close()