Merge "Remove unused None from dict.get()"

This commit is contained in:
Jenkins 2017-06-29 02:39:44 +00:00 committed by Gerrit Code Review
commit e62d586a6d
10 changed files with 19 additions and 20 deletions

View File

@ -442,7 +442,7 @@ class Endpoints(object):
queue_max_msg_size = queue_meta.get('_max_messages_post_size', queue_max_msg_size = queue_meta.get('_max_messages_post_size',
None) None)
queue_default_ttl = queue_meta.get('_default_message_ttl', None) queue_default_ttl = queue_meta.get('_default_message_ttl')
# TODO(flwang): To avoid any unexpected regression issue, we just # TODO(flwang): To avoid any unexpected regression issue, we just
# leave the _message_post_spec attribute of class as it's. It # leave the _message_post_spec attribute of class as it's. It

View File

@ -241,7 +241,7 @@ def inject_context(req, resp, params):
""" """
client_id = req.get_header('Client-ID') client_id = req.get_header('Client-ID')
project_id = params.get('project_id', None) project_id = params.get('project_id')
request_id = req.headers.get('X-Openstack-Request-ID'), request_id = req.headers.get('X-Openstack-Request-ID'),
auth_token = req.headers.get('X-AUTH-TOKEN') auth_token = req.headers.get('X-AUTH-TOKEN')
user = req.headers.get('X-USER-ID') user = req.headers.get('X-USER-ID')

View File

@ -111,12 +111,12 @@ class NotifierDriver(object):
messages = {} messages = {}
endpoint_dict = auth.get_public_endpoint() endpoint_dict = auth.get_public_endpoint()
if endpoint_dict: if endpoint_dict:
wsgi_endpoint = endpoint_dict.get('zaqar', None) wsgi_endpoint = endpoint_dict.get('zaqar')
if wsgi_endpoint: if wsgi_endpoint:
wsgi_subscribe_url = urllib_parse.urljoin( wsgi_subscribe_url = urllib_parse.urljoin(
wsgi_endpoint, url) wsgi_endpoint, url)
messages['WSGISubscribeURL'] = wsgi_subscribe_url messages['WSGISubscribeURL'] = wsgi_subscribe_url
websocket_endpoint = endpoint_dict.get('zaqar-websocket', None) websocket_endpoint = endpoint_dict.get('zaqar-websocket')
if websocket_endpoint: if websocket_endpoint:
websocket_subscribe_url = urllib_parse.urljoin( websocket_subscribe_url = urllib_parse.urljoin(
websocket_endpoint, url) websocket_endpoint, url)

View File

@ -134,7 +134,7 @@ class SubscriptionController(base.Subscription):
assert fields, ('`subscriber`, `ttl`, ' assert fields, ('`subscriber`, `ttl`, '
'or `options` not found in kwargs') 'or `options` not found in kwargs')
new_ttl = fields.get('t', None) new_ttl = fields.get('t')
if new_ttl is not None: if new_ttl is not None:
now = timeutils.utcnow_ts() now = timeutils.utcnow_ts()
now_dt = datetime.datetime.utcfromtimestamp(now) now_dt = datetime.datetime.utcfromtimestamp(now)

View File

@ -207,7 +207,7 @@ class QueueController(storage.Queue):
def _create(self, name, metadata=None, project=None): def _create(self, name, metadata=None, project=None):
flavor = None flavor = None
if isinstance(metadata, dict): if isinstance(metadata, dict):
flavor = metadata.get('_flavor', None) flavor = metadata.get('_flavor')
self._pool_catalog.register(name, project=project, flavor=flavor) self._pool_catalog.register(name, project=project, flavor=flavor)

View File

@ -196,7 +196,7 @@ class SubscriptionController(base.Subscription):
subscription_to_update = self.get(queue, subscription_id, subscription_to_update = self.get(queue, subscription_id,
project=project) project=project)
new_subscriber = fields.get('u', None) new_subscriber = fields.get('u')
# Let's do some checks to prevent subscription duplication. # Let's do some checks to prevent subscription duplication.
if new_subscriber: if new_subscriber:
@ -210,11 +210,11 @@ class SubscriptionController(base.Subscription):
# NOTE(Eva-i): if there are new options, we need to pack them before # NOTE(Eva-i): if there are new options, we need to pack them before
# sending to the database. # sending to the database.
new_options = fields.get('o', None) new_options = fields.get('o')
if new_options is not None: if new_options is not None:
fields['o'] = self._packer(new_options) fields['o'] = self._packer(new_options)
new_ttl = fields.get('t', None) new_ttl = fields.get('t')
if new_ttl is not None: if new_ttl is not None:
now = timeutils.utcnow_ts() now = timeutils.utcnow_ts()
expires = now + new_ttl expires = now + new_ttl

View File

@ -300,7 +300,7 @@ class Validator(object):
if not queue_metadata: if not queue_metadata:
return return
queue_default_ttl = queue_metadata.get('_default_message_ttl', None) queue_default_ttl = queue_metadata.get('_default_message_ttl')
if queue_default_ttl and not isinstance(queue_default_ttl, int): if queue_default_ttl and not isinstance(queue_default_ttl, int):
msg = _(u'_default_message_ttl must be integer.') msg = _(u'_default_message_ttl must be integer.')
raise ValidationFailed(msg) raise ValidationFailed(msg)
@ -525,7 +525,7 @@ class Validator(object):
msg = _('Subscriptions must be a dict.') msg = _('Subscriptions must be a dict.')
raise ValidationFailed(msg) raise ValidationFailed(msg)
subscriber = subscription.get('subscriber', None) subscriber = subscription.get('subscriber')
subscriber_type = None subscriber_type = None
if subscriber: if subscriber:
@ -537,12 +537,12 @@ class Validator(object):
u'supported in the list {0}.') u'supported in the list {0}.')
raise ValidationFailed(msg, self._limits_conf.subscriber_types) raise ValidationFailed(msg, self._limits_conf.subscriber_types)
options = subscription.get('options', None) options = subscription.get('options')
if options and not isinstance(options, dict): if options and not isinstance(options, dict):
msg = _(u'Options must be a dict.') msg = _(u'Options must be a dict.')
raise ValidationFailed(msg) raise ValidationFailed(msg)
ttl = subscription.get('ttl', None) ttl = subscription.get('ttl')
if ttl: if ttl:
if not isinstance(ttl, int): if not isinstance(ttl, int):
msg = _(u'TTL must be an integer.') msg = _(u'TTL must be an integer.')
@ -568,7 +568,7 @@ class Validator(object):
raise ValidationFailed(msg, datetime.datetime.max) raise ValidationFailed(msg, datetime.datetime.max)
def subscription_confirming(self, confirmed): def subscription_confirming(self, confirmed):
confirmed = confirmed.get('confirmed', None) confirmed = confirmed.get('confirmed')
if not isinstance(confirmed, bool): if not isinstance(confirmed, bool):
msg = _(u"The 'confirmed' should be boolean.") msg = _(u"The 'confirmed' should be boolean.")
raise ValidationFailed(msg) raise ValidationFailed(msg)

View File

@ -172,9 +172,8 @@ class CollectionResource(object):
# set. # set.
queue_meta = {} queue_meta = {}
queue_max_msg_size = queue_meta.get('_max_messages_post_size', queue_max_msg_size = queue_meta.get('_max_messages_post_size')
None) queue_default_ttl = queue_meta.get('_default_message_ttl')
queue_default_ttl = queue_meta.get('_default_message_ttl', None)
# TODO(flwang): To avoid any unexpected regression issue, we just # TODO(flwang): To avoid any unexpected regression issue, we just
# leave the _message_post_spec attribute of class as it's. It # leave the _message_post_spec attribute of class as it's. It

View File

@ -56,7 +56,7 @@ class ItemResource(object):
resp_dict = self._queue_controller.get(queue_name, resp_dict = self._queue_controller.get(queue_name,
project=project_id) project=project_id)
for meta, value in _get_reserved_metadata(self._validate).items(): for meta, value in _get_reserved_metadata(self._validate).items():
if not resp_dict.get(meta, None): if not resp_dict.get(meta):
resp_dict[meta] = value resp_dict[meta] = value
except storage_errors.DoesNotExist as ex: except storage_errors.DoesNotExist as ex:
LOG.debug(ex) LOG.debug(ex)
@ -209,7 +209,7 @@ class ItemResource(object):
description = _(u'Queue could not be updated.') description = _(u'Queue could not be updated.')
raise wsgi_errors.HTTPServiceUnavailable(description) raise wsgi_errors.HTTPServiceUnavailable(description)
for meta, value in _get_reserved_metadata(self._validate).items(): for meta, value in _get_reserved_metadata(self._validate).items():
if not metadata.get(meta, None): if not metadata.get(meta):
metadata[meta] = value metadata[meta] = value
resp.body = utils.to_json(metadata) resp.body = utils.to_json(metadata)

View File

@ -267,7 +267,7 @@ class ConfirmResource(object):
try: try:
self._validate.subscription_confirming(document) self._validate.subscription_confirming(document)
confirmed = document.get('confirmed', None) confirmed = document.get('confirmed')
self._subscription_controller.confirm(queue_name, subscription_id, self._subscription_controller.confirm(queue_name, subscription_id,
project=project_id, project=project_id,
confirmed=confirmed) confirmed=confirmed)