From d7d0d13ee01d6ad601643cc09900c38e3ca96429 Mon Sep 17 00:00:00 2001 From: Vyacheslav Vakhlyuev Date: Mon, 24 Feb 2014 14:53:05 +0400 Subject: [PATCH] Replaced calls of get(foo, None) -> get(foo) If no default value is specified, the get method of dictionaries defaults to 'None' already. So removing the 'None' argument to make the code more clean and readable. Change-Id: I2f29315488d515aa2837d06ea59ab41e8ca05fc8 --- glance/api/middleware/cache.py | 4 ++-- glance/api/v1/images.py | 2 +- glance/api/v1/upload_utils.py | 2 +- glance/api/v2/images.py | 2 +- glance/api/v2/tasks.py | 4 ++-- glance/db/simple/api.py | 2 +- glance/db/sqlalchemy/api.py | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/glance/api/middleware/cache.py b/glance/api/middleware/cache.py index 89ec8b5693..4cf882ab74 100644 --- a/glance/api/middleware/cache.py +++ b/glance/api/middleware/cache.py @@ -240,11 +240,11 @@ class CacheFilter(wsgi.Middleware): return resp def _process_GET_response(self, resp, image_id): - image_checksum = resp.headers.get('Content-MD5', None) + image_checksum = resp.headers.get('Content-MD5') if not image_checksum: # API V1 stores the checksum in a different header: - image_checksum = resp.headers.get('x-image-meta-checksum', None) + image_checksum = resp.headers.get('x-image-meta-checksum') if not image_checksum: LOG.error(_("Checksum header is missing.")) diff --git a/glance/api/v1/images.py b/glance/api/v1/images.py index 6102ef9185..560cc532b8 100644 --- a/glance/api/v1/images.py +++ b/glance/api/v1/images.py @@ -868,7 +868,7 @@ class Controller(controller.BaseController): activating = orig_status == 'queued' and (location or image_data) # Make image public in the backend store (if implemented) - orig_or_updated_loc = location or orig_image_meta.get('location', None) + orig_or_updated_loc = location or orig_image_meta.get('location') if orig_or_updated_loc: try: self.update_store_acls(req, id, orig_or_updated_loc, diff --git a/glance/api/v1/upload_utils.py b/glance/api/v1/upload_utils.py index 97d4e7c92a..bdb34823a9 100644 --- a/glance/api/v1/upload_utils.py +++ b/glance/api/v1/upload_utils.py @@ -81,7 +81,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier): image_id = image_meta['id'] db_api = glance.db.get_api() - image_size = image_meta.get('size', None) + image_size = image_meta.get('size') try: remaining = glance.api.common.check_quota( diff --git a/glance/api/v2/images.py b/glance/api/v2/images.py index 7b516a4c3b..9b6e7e5408 100644 --- a/glance/api/v2/images.py +++ b/glance/api/v2/images.py @@ -508,7 +508,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer): return member_status def _get_filters(self, filters): - visibility = filters.get('visibility', None) + visibility = filters.get('visibility') if visibility: if visibility not in ['public', 'private', 'shared']: msg = _('Invalid visibility value: %s') % visibility diff --git a/glance/api/v2/tasks.py b/glance/api/v2/tasks.py index c4770ef183..1fec2ac9b9 100644 --- a/glance/api/v2/tasks.py +++ b/glance/api/v2/tasks.py @@ -137,13 +137,13 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer): return sort_dir def _get_filters(self, filters): - status = filters.get('status', None) + status = filters.get('status') if status: if status not in ['pending', 'processing', 'success', 'failure']: msg = _('Invalid status value: %s') % status raise webob.exc.HTTPBadRequest(explanation=msg) - type = filters.get('type', None) + type = filters.get('type') if type: if type not in ['import']: msg = _('Invalid type value: %s') % type diff --git a/glance/db/simple/api.py b/glance/db/simple/api.py index cfdf1fbda3..447ec01be4 100644 --- a/glance/db/simple/api.py +++ b/glance/db/simple/api.py @@ -524,7 +524,7 @@ def image_create(context, image_values): image = _image_format(image_id, **image_values) DATA['images'][image_id] = image - location_data = image_values.get('locations', None) + location_data = image_values.get('locations') if location_data is not None: _image_locations_set(image_id, location_data) diff --git a/glance/db/sqlalchemy/api.py b/glance/db/sqlalchemy/api.py index 8e2b1db27c..4c6e27779f 100644 --- a/glance/db/sqlalchemy/api.py +++ b/glance/db/sqlalchemy/api.py @@ -562,7 +562,7 @@ def _validate_image(values): :param values: Mapping of image metadata to check """ - status = values.get('status', None) + status = values.get('status') if not status: msg = "Image status is required." raise exception.Invalid(msg)