Avoid Forcing the Translation of Translatable Variables

Whenever possible translation should not be forced by use of six.text_type()
or str() on messages being used with a format string.

http://docs.openstack.org/developer/oslo.i18n/guidelines.html#avoid-forcing-the-translation-of-translatable-variables

Change-Id: If8eeeebd6fafc647a632bdff5636f82d383e2164
This commit is contained in:
Luong Anh Tuan 2016-09-28 16:09:10 +07:00 committed by Tuan Luong-Anh
parent 5c794d4f98
commit 4c6ce2f938
8 changed files with 11 additions and 14 deletions

View File

@ -19,7 +19,6 @@ import os
from oslo_config import cfg
from oslo_log import log
from oslo_utils import importutils
import six
import webob.dec
import webob.exc
@ -183,8 +182,7 @@ class ExtensionManager(object):
' '.join(extension.__doc__.strip().split()))
LOG.debug('Ext updated: %s', extension.updated)
except AttributeError as ex:
LOG.exception(_LE("Exception loading extension: %s"),
six.text_type(ex))
LOG.exception(_LE("Exception loading extension: %s"), ex)
return False
return True

View File

@ -41,7 +41,7 @@ class FaultWrapper(base_wsgi.Middleware):
status, webob.exc.HTTPInternalServerError)()
def _error(self, inner, req):
LOG.exception(_LE("Caught error: %s"), six.text_type(inner))
LOG.exception(_LE("Caught error: %s"), inner)
safe = getattr(inner, 'safe', False)
headers = getattr(inner, 'headers', None)

View File

@ -528,10 +528,10 @@ class ResourceExceptionHandler(object):
ex_value, exc_info=exc_info)
raise Fault(webob.exc.HTTPBadRequest())
elif isinstance(ex_value, Fault):
LOG.info(_LI("Fault thrown: %s"), six.text_type(ex_value))
LOG.info(_LI("Fault thrown: %s"), ex_value)
raise ex_value
elif isinstance(ex_value, webob.exc.HTTPException):
LOG.info(_LI("HTTP exception thrown: %s"), six.text_type(ex_value))
LOG.info(_LI("HTTP exception thrown: %s"), ex_value)
raise Fault(ex_value)
# We didn't handle the exception

View File

@ -15,7 +15,6 @@
import os
from oslo_log import log
import six
from manila import exception
from manila.i18n import _
@ -89,7 +88,7 @@ class Copy(object):
self.copy_stats(self.src)
self.completed = True
LOG.info(six.text_type(self.get_progress()))
LOG.info(self.get_progress())
def get_total_size(self, path):
if self.cancelled:
@ -144,7 +143,7 @@ class Copy(object):
self._copy_and_validate(src_item, dest_item)
self.current_size += int(size)
LOG.info(six.text_type(self.get_progress()))
LOG.info(self.get_progress())
@utils.retry(exception.ShareDataCopyFailed, retries=2)
def _copy_and_validate(self, src_item, dest_item):

View File

@ -1235,7 +1235,7 @@ class API(base.Base):
if search_opts is None:
search_opts = {}
LOG.debug("Searching for shares by: %s", six.text_type(search_opts))
LOG.debug("Searching for shares by: %s", search_opts)
# Prepare filters
filters = {}
@ -1302,7 +1302,7 @@ class API(base.Base):
policy.check_policy(context, 'share_snapshot', 'get_all_snapshots')
search_opts = search_opts or {}
LOG.debug("Searching for snapshots by: %s", six.text_type(search_opts))
LOG.debug("Searching for snapshots by: %s", search_opts)
# Read and remove key 'all_tenants' if was provided
all_tenants = search_opts.pop('all_tenants', None)

View File

@ -86,7 +86,7 @@ class DockerExecHelper(driver.ExecuteMixin):
LOG.debug("Executing inside a container %s.", name)
cmd = ["docker", "exec", "-i", name] + cmd
result = self._inner_execute(cmd)
LOG.debug("Run result: %s.", str(result))
LOG.debug("Run result: %s.", result)
return result
def _inner_execute(self, cmd):

View File

@ -2030,7 +2030,7 @@ class ShareManager(manager.SchedulerDependentManager):
def share_manage_set_error_status(msg, exception):
status = {'status': constants.STATUS_UNMANAGE_ERROR}
self.db.share_update(context, share_id, status)
LOG.error(msg, six.text_type(exception))
LOG.error(msg, exception)
try:
if self.driver.driver_handles_share_servers:

View File

@ -448,7 +448,7 @@ def tempdir(**kwargs):
try:
shutil.rmtree(tmpdir)
except OSError as e:
LOG.debug('Could not remove tmpdir: %s', six.text_type(e))
LOG.debug('Could not remove tmpdir: %s', e)
def walk_class_hierarchy(clazz, encountered=None):