Move from using _ builtin to using glance.i18n _

The builtin _ should not longer be used.  Instead _
should be explicitly assigned from glance.i18n.

This patch does the following:
  (1) adds these explict assignments to any
      glance file that was missing them,
  (2) removes the defintion of _ as a builtin from
      tox.ini so that a pep8 failure will occur
      if _ is not defined,
  (3) removes calls to install().

This removes the last direct use of gettextutils by glance.
The indirect uses, via openstack/common, will be removed
in the next sync with oslo.

Change-Id: Ie54e8a67e747e022cc01022dfad35d89686bdfc4
This commit is contained in:
James Carey 2014-11-10 20:33:33 +00:00 committed by James Carey
parent fa7888d920
commit 3f2a56ae65
65 changed files with 108 additions and 14 deletions

View File

@ -18,6 +18,9 @@ import copy
from glance.common import exception
import glance.domain.proxy
from glance import i18n
_ = i18n._
def is_image_mutable(context, image):

View File

@ -24,6 +24,7 @@ from glance import i18n
from glance.openstack.common import log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI
_LW = i18n._LW

View File

@ -20,9 +20,11 @@ import webob.exc
from glance.api import policy
from glance.common import wsgi
import glance.context
from glance import i18n
from glance.openstack.common import local
import glance.openstack.common.log as logging
_ = i18n._
context_opts = [
cfg.BoolOpt('owner_is_tenant', default=True,

View File

@ -29,7 +29,7 @@ import glance.openstack.common.log as logging
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
_ = i18n._
_LW = i18n._LW

View File

@ -29,7 +29,7 @@ import glance.openstack.common.log as logging
from glance.openstack.common import policy
LOG = logging.getLogger(__name__)
_ = i18n._
_LI = i18n._LI
_LW = i18n._LW

View File

@ -17,11 +17,13 @@ import glance_store as store
import webob.exc
from glance.common import exception
from glance import i18n
import glance.openstack.common.log as logging
import glance.registry.client.v1.api as registry
LOG = logging.getLogger(__name__)
_ = i18n._
class BaseController(object):

View File

@ -50,6 +50,7 @@ import glance.openstack.common.log as logging
import glance.registry.client.v1.api as registry
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI
_LW = i18n._LW

View File

@ -22,10 +22,12 @@ from glance.api.v1 import controller
from glance.common import exception
from glance.common import utils
from glance.common import wsgi
from glance import i18n
import glance.openstack.common.log as logging
import glance.registry.client.v1.api as registry
LOG = logging.getLogger(__name__)
_ = i18n._
CONF = cfg.CONF
CONF.import_opt('image_member_quota', 'glance.common.config')

View File

@ -28,6 +28,7 @@ import glance.registry.client.v1.api as registry
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI
_LW = i18n._LW

View File

@ -28,6 +28,7 @@ import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE

View File

@ -36,6 +36,7 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_ = i18n._
_LW = i18n._LW
CONF = cfg.CONF

View File

@ -38,6 +38,7 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LW = i18n._LW
_LI = i18n._LI

View File

@ -34,6 +34,7 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI

View File

@ -34,6 +34,7 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI

View File

@ -34,6 +34,7 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI

View File

@ -36,6 +36,7 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_ = i18n._
_LW = i18n._LW
CONF = cfg.CONF

View File

@ -20,7 +20,9 @@ from oslo.serialization import jsonutils
import webob.dec
from glance.common import wsgi
from glance import i18n
_ = i18n._
versions_opts = [
cfg.StrOpt('public_endpoint', default=None,

View File

@ -16,4 +16,3 @@
from glance import i18n
i18n.enable_lazy()
i18n.install('glance')

View File

@ -44,7 +44,9 @@ from oslo.utils import units
from six.moves import xrange
from glance.common import config
from glance import i18n
_ = i18n._
CONF = cfg.CONF

View File

@ -33,6 +33,7 @@ from glance import i18n
from glance.openstack.common import log
LOG = log.getLogger(__name__)
_ = i18n._
_LI = i18n._LI
_LE = i18n._LE
_LW = i18n._LW

View File

@ -33,10 +33,12 @@ from oslo.serialization import jsonutils
import six.moves.urllib.parse as urlparse
from glance.common import exception
from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
class BaseStrategy(object):

View File

@ -48,9 +48,11 @@ from six.moves import xrange
from glance.common import auth
from glance.common import exception
from glance.common import utils
from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
# common chunk size for get and put
CHUNKSIZE = 65536

View File

@ -27,8 +27,11 @@ import os
from oslo.config import cfg
from paste import deploy
from glance import i18n
from glance.version import version_info as version
_ = i18n._
paste_deploy_opts = [
cfg.StrOpt('flavor',
help=_('Partial name of a pipeline in your paste configuration '

View File

@ -19,6 +19,10 @@
import six
import six.moves.urllib.parse as urlparse
from glance import i18n
_ = i18n._
_FATAL_EXCEPTION_FORMAT_ERRORS = False

View File

@ -18,8 +18,11 @@ import copy
from oslo.config import cfg
import stevedore
from glance import i18n
import glance.openstack.common.log as logging
_ = i18n._
location_strategy_opts = [
cfg.StrOpt('location_strategy', default='location_order',
help=_("This value sets what strategy will be used to "

View File

@ -19,6 +19,10 @@ from oslo.config import cfg
import six
import six.moves.urllib.parse as urlparse
from glance import i18n
_ = i18n._
store_type_opts = [
cfg.ListOpt("store_type_preference",
default=[],

View File

@ -23,6 +23,7 @@ from oslo.config import cfg
import glance.api.policy
from glance.common import exception
from glance import i18n
from glance.openstack.common import log as logging
from glance.openstack.common import policy
@ -30,6 +31,7 @@ from glance.openstack.common import policy
# we must set manually for compatibility with py26
CONFIG = ConfigParser.SafeConfigParser(dict_type=OrderedDict)
LOG = logging.getLogger(__name__)
_ = i18n._
property_opts = [
cfg.StrOpt('property_protection_file',

View File

@ -29,9 +29,11 @@ from glance.common import client
from glance.common import exception
from glance.common import utils
from glance.common import wsgi
from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
rpc_opts = [

View File

@ -30,10 +30,11 @@ from glance.openstack.common import lockutils
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI
_LW = i18n._LW
LOG = logging.getLogger(__name__)
def run(t_id, context, task_repo, image_repo, image_factory):

View File

@ -29,8 +29,9 @@ from glance import i18n
import glance.openstack.common.log as logging
_LE = i18n._LE
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
def get_task(task_repo, task_id):

View File

@ -23,11 +23,11 @@ from glance import i18n
import glance.openstack.common.log as logging
from glance import scrubber
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LW = i18n._LW
LOG = logging.getLogger(__name__)
store_utils_opts = [
cfg.BoolOpt('use_user_token', default=True,
help=_('Whether to pass through the user token when '

View File

@ -21,8 +21,11 @@ except ImportError:
from oslo.config import cfg
from glance.common import exception
from glance import i18n
from glance.openstack.common import log as logging
_ = i18n._
swift_opts = [
cfg.StrOpt('default_swift_reference',
default="ref1",

View File

@ -46,11 +46,13 @@ import six
from webob import exc
from glance.common import exception
from glance import i18n
import glance.openstack.common.log as logging
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
_ = i18n._
FEATURE_BLACKLIST = ['content-length', 'content-type', 'x-image-meta-size']

View File

@ -49,6 +49,7 @@ from glance import i18n
import glance.openstack.common.log as logging
from glance.openstack.common import processutils
_ = i18n._
bind_opts = [
cfg.StrOpt('bind_host', default='0.0.0.0',

View File

@ -26,6 +26,9 @@ from glance.common import exception
from glance.common import location_strategy
import glance.domain
import glance.domain.proxy
from glance import i18n
_ = i18n._
CONF = cfg.CONF
CONF.import_opt('image_size_cap', 'glance.common.config')

View File

@ -27,6 +27,7 @@ import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LI = i18n._LI
_LW = i18n._LW

View File

@ -49,6 +49,7 @@ import glance.openstack.common.log as os_logging
BASE = models.BASE
sa_logger = None
LOG = os_logging.getLogger(__name__)
_ = i18n._
_LI = i18n._LI
_LW = i18n._LW

View File

@ -35,6 +35,7 @@ from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LW = i18n._LW
_LI = i18n._LI

View File

@ -25,6 +25,7 @@ from glance import i18n
import glance.openstack.common.log as os_logging
LOG = os_logging.getLogger(__name__)
_ = i18n._
_LW = i18n._LW

View File

@ -25,6 +25,7 @@ from glance import i18n
import glance.openstack.common.log as os_logging
LOG = os_logging.getLogger(__name__)
_ = i18n._
_LW = i18n._LW

View File

@ -25,6 +25,7 @@ from glance import i18n
import glance.openstack.common.log as os_logging
LOG = os_logging.getLogger(__name__)
_ = i18n._
_LW = i18n._LW

View File

@ -22,6 +22,7 @@ from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE

View File

@ -41,6 +41,7 @@ from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI
_LW = i18n._LW

View File

@ -28,6 +28,7 @@ from glance.common import exception
from glance import i18n
import glance.openstack.common.log as logging
_ = i18n._
_LE = i18n._LE
LOG = logging.getLogger(__name__)
CONF = cfg.CONF

View File

@ -30,6 +30,7 @@ from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI
_LW = i18n._LW

View File

@ -19,6 +19,9 @@ from oslo.serialization import jsonutils as json
from glance.common import client as base_client
from glance.common import exception
from glance import i18n
_ = i18n._
class CacheClient(base_client.BaseClient):

View File

@ -23,9 +23,11 @@ from oslo.config import cfg
from glance.common import exception
from glance.common import utils
from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
CONF = cfg.CONF

View File

@ -35,6 +35,7 @@ from glance.image_cache.drivers import base
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI
_LW = i18n._LW

View File

@ -26,7 +26,7 @@ import glance.domain.proxy
from glance import i18n
import glance.openstack.common.log as logging
_ = i18n._
_LE = i18n._LE
CONF = cfg.CONF

View File

@ -24,8 +24,11 @@ import webob
from glance.common import exception
from glance.common import utils
import glance.domain.proxy
from glance import i18n
import glance.openstack.common.log as logging
_ = i18n._
notifier_opts = [
cfg.StrOpt('default_publisher_id', default="image.localhost",
help='Default publisher_id for outgoing notifications.'),

View File

@ -35,7 +35,6 @@ import glance.common.wsgi
import glance.image_cache
import glance.image_cache.drivers.sqlite
import glance.notifier
from glance.openstack.common import gettextutils
import glance.openstack.common.lockutils
import glance.openstack.common.log
import glance.registry
@ -43,10 +42,6 @@ import glance.registry.client
import glance.registry.client.v1.api
import glance.scrubber
# TODO(zhiyan): Remove translation from in-line
# help message of option definition code.
gettextutils.install('glance', lazy=False)
_global_opt_lists = [
glance.openstack.common.log.common_cli_opts,

View File

@ -29,6 +29,7 @@ import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LI = i18n._LI
CONF = cfg.CONF
CONF.import_opt('image_member_quota', 'glance.common.config')

View File

@ -19,6 +19,9 @@ Registry API
from oslo.config import cfg
from glance import i18n
_ = i18n._
registry_addr_opts = [
cfg.StrOpt('registry_host', default='0.0.0.0',

View File

@ -31,6 +31,7 @@ import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI
_LW = i18n._LW

View File

@ -24,6 +24,7 @@ import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
_LI = i18n._LI
_LW = i18n._LW

View File

@ -22,10 +22,12 @@ from oslo.config import cfg
from glance.common import rpc
from glance.common import wsgi
import glance.db
from glance import i18n
import glance.openstack.common.log as logging
LOG = logging.getLogger(__name__)
_ = i18n._
CONF = cfg.CONF

View File

@ -15,6 +15,10 @@
from oslo.config import cfg
from glance import i18n
_ = i18n._
registry_client_opts = [
cfg.StrOpt('registry_client_protocol', default='http',
help=_('The protocol to use for communication with the '

View File

@ -23,10 +23,12 @@ from oslo.config import cfg
from oslo.serialization import jsonutils
from glance.common import exception
from glance import i18n
import glance.openstack.common.log as logging
from glance.registry.client.v1 import client
LOG = logging.getLogger(__name__)
_ = i18n._
registry_client_ctx_opts = [
cfg.BoolOpt('send_identity_headers', default=False,

View File

@ -22,10 +22,12 @@ import os
from oslo.config import cfg
from glance.common import exception
from glance import i18n
import glance.openstack.common.log as logging
from glance.registry.client.v2 import client
LOG = logging.getLogger(__name__)
_ = i18n._
CONF = cfg.CONF
_registry_client = 'glance.registry.client'

View File

@ -18,6 +18,9 @@ import six
from glance.common import exception
from glance.common import utils
from glance import i18n
_ = i18n._
class Schema(object):

View File

@ -34,6 +34,7 @@ import glance.registry.client.v1.api as registry
LOG = logging.getLogger(__name__)
_ = i18n._
_LI = i18n._LI
_LW = i18n._LW
_LE = i18n._LE

View File

@ -34,6 +34,7 @@ import glance.openstack.common.log as logging
import glance.schema
LOG = logging.getLogger(__name__)
_ = i18n._
_LE = i18n._LE
_LI = i18n._LI

View File

@ -48,7 +48,9 @@ from glance.db import migration
from glance.db.sqlalchemy import migrate_repo
from glance.db.sqlalchemy.migrate_repo.schema import from_migration_import
from glance.db.sqlalchemy import models
from glance import i18n
_ = i18n._
CONF = cfg.CONF
CONF.import_opt('metadata_encryption_key', 'glance.common.config')

View File

@ -31,12 +31,14 @@ from glance.common import config
from glance.common import exception
from glance import context
from glance.db.sqlalchemy import api as db_api
from glance import i18n
from glance.registry.api import v2 as rserver
import glance.registry.client.v2.api as rapi
from glance.registry.client.v2.api import client as rclient
from glance.tests.unit import base
from glance.tests import utils as test_utils
_ = i18n._
_gen_uuid = lambda: str(uuid.uuid4())

View File

@ -50,7 +50,6 @@ commands = python setup.py build_sphinx
# H405 multi line docstring summary not separated with an empty line
# H904 Wrap long lines in parentheses instead of a backslash
ignore = E711,E712,H302,H402,H404,H405,H904
builtins = _
exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build
[hacking]