Switch heat resources & db & tests to oslo.i18n

Use oslo.i18n in resources & db & tests directories.

blueprint oslo-i18n

Change-Id: Idaf718b9d762b9ae89d6045557eadb758b552bd5
This commit is contained in:
Ethan Lynn 2014-07-25 15:10:38 +08:00
parent c2211f0e0a
commit 6d0cd62172
39 changed files with 52 additions and 48 deletions

View File

@ -16,10 +16,10 @@
import six
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -19,7 +19,7 @@ from keystoneclient.v2_0 import client as kc
from oslo.config import cfg
from heat.common import exception
from heat.openstack.common.gettextutils import _
from heat.common.i18n import _
from heat.openstack.common import importutils
from heat.openstack.common import log as logging

View File

@ -11,9 +11,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
class NovaFlavor(resource.Resource):

View File

@ -18,13 +18,13 @@ import urlparse
from oslo.config import cfg
from heat.common import exception
from heat.common.i18n import _
from heat.engine.clients import client_plugin
from heat.engine.clients.os import cinder
from heat.engine.clients.os import glance
from heat.engine.clients.os import nova
from heat.engine.clients.os import trove
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
from glanceclient import client as gc

View File

@ -14,10 +14,10 @@
"""Resources for Rackspace DNS."""
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
try:

View File

@ -17,6 +17,7 @@ import itertools
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import function
@ -24,7 +25,6 @@ from heat.engine import properties
from heat.engine.properties import Properties
from heat.engine import resource
from heat.engine import scheduler
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
try:

View File

@ -14,10 +14,10 @@
import copy
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine.resources import server
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
try:

View File

@ -14,11 +14,11 @@
import netaddr
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
try:

View File

@ -19,13 +19,13 @@ from docutils import nodes
import pydoc
from sphinx.util.compat import Directive
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import environment
from heat.engine import plugin_manager
from heat.engine import properties
from heat.engine import resources
from heat.engine import support
from heat.openstack.common.gettextutils import _
global_env = environment.Environment({}, user_env=False)

View File

@ -108,9 +108,9 @@ plug-in.
.. code-block:: python
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.openstack.common.gettextutils import _
nested_schema = {
"foo": properties.Schema(

View File

@ -14,7 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.openstack.common import gettextutils
from oslo import i18n
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
i18n.enable_lazy()
# fixme(elynn): Since install() is deprecated, we should remove it in
# the future
i18n.install('heat')

View File

@ -25,10 +25,10 @@ from sqlalchemy.orm.session import Session
from heat.common import crypt
from heat.common import exception
from heat.common.i18n import _
from heat.db.sqlalchemy import filters as db_filters
from heat.db.sqlalchemy import migration
from heat.db.sqlalchemy import models
from heat.openstack.common.gettextutils import _
CONF = cfg.CONF
CONF.import_opt('max_events_per_stack', 'heat.common.config')

View File

@ -16,7 +16,7 @@ import uuid
from migrate.versioning import util as migrate_util
import sqlalchemy
from heat.openstack.common.gettextutils import _
from heat.common.i18n import _
def upgrade(migrate_engine):

View File

@ -17,9 +17,9 @@ from migrate.versioning import util as migrate_util
import six
from sqlalchemy.orm import sessionmaker
from heat.common.i18n import _
from heat.db.sqlalchemy import models
from heat.engine.hot.parameters import HOTParamSchema
from heat.openstack.common.gettextutils import _
def upgrade(migrate_engine):

View File

@ -16,8 +16,8 @@ from migrate.versioning import util as migrate_util
import six
from sqlalchemy.orm import sessionmaker
from heat.common.i18n import _
from heat.db.sqlalchemy import models
from heat.openstack.common.gettextutils import _
def upgrade(migrate_engine):

View File

@ -16,8 +16,8 @@ import time
from migrate.versioning import util as migrate_util
from sqlalchemy.orm import sessionmaker
from heat.common.i18n import _
from heat.db.sqlalchemy import models
from heat.openstack.common.gettextutils import _
def upgrade(migrate_engine):

View File

@ -17,12 +17,14 @@ from __future__ import print_function
import sys
from oslo.config import cfg
from oslo import i18n
from heat.db import migration
from heat.openstack.common import gettextutils
from heat.openstack.common import log as logging
gettextutils.install('heat')
# fixme(elynn): Since install() is deprecated, we should remove it in
# the future
i18n.install('heat')
LOG = logging.getLogger(__name__)

View File

@ -12,13 +12,13 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.vpc import VPC
from heat.openstack.common import excutils
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -11,10 +11,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
class GlanceImage(resource.Resource):

View File

@ -17,6 +17,7 @@ from oslo.config import cfg
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
@ -24,7 +25,6 @@ from heat.engine import resource
from heat.engine.resources import volume
from heat.engine import scheduler
from heat.engine import signal_responder
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
cfg.CONF.import_opt('instance_user', 'heat.common.config')

View File

@ -12,10 +12,10 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources import route_table
from heat.openstack.common.gettextutils import _
class InternetGateway(resource.Resource):

View File

@ -15,12 +15,12 @@ import os
from oslo.config import cfg
from heat.common import exception
from heat.common.i18n import _
from heat.common import template_format
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import stack_resource
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -11,11 +11,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common import excutils
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -12,11 +12,11 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
class KeyPair(resource.Resource):

View File

@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
class ServerGroup(resource.Resource):

View File

@ -27,8 +27,8 @@ from six.moves.urllib import parse as urlparse
import warnings
from heat.common import exception
from heat.common.i18n import _
from heat.engine import scheduler
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -12,11 +12,11 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
from heat.openstack.common import uuidutils

View File

@ -17,12 +17,12 @@ import string
from six.moves import xrange
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine import support
from heat.openstack.common.gettextutils import _
class RandomString(resource.Resource):

View File

@ -15,12 +15,12 @@ import collections
import copy
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import stack_resource
from heat.engine import template
from heat.openstack.common.gettextutils import _
template_template = {
"heat_template_version": "2013-05-23",

View File

@ -14,11 +14,11 @@
# limitations under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -14,10 +14,10 @@
# limitations under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -17,6 +17,7 @@ import uuid
from oslo.config import cfg
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
@ -25,7 +26,6 @@ from heat.engine.resources.neutron import subnet
from heat.engine import scheduler
from heat.engine import stack_user
from heat.engine import support
from heat.openstack.common.gettextutils import _
from heat.openstack.common import jsonutils
from heat.openstack.common import log as logging
from heat.openstack.common import uuidutils

View File

@ -16,10 +16,10 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import os
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine.resources.software_config import software_config
from heat.openstack.common.gettextutils import _
class MultipartMime(software_config.SoftwareConfig):

View File

@ -11,11 +11,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -17,13 +17,13 @@ import urlparse
from swiftclient import client as swiftclient_client
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine.clients.os import swift
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine import scheduler
from heat.openstack.common.gettextutils import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -11,18 +11,18 @@
# License for the specific language governing permissions and limitations
# under the License.
# See http://code.google.com/p/python-nose/issues/detail?id=373
# The code below enables nosetests to work with i18n _() blocks
from heat.openstack.common import gettextutils
from oslo import i18n
def fake_translate_msgid(msgid, domain, desired_locale=None):
return msgid
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
i18n.enable_lazy()
# fixme(elynn): Since install() is deprecated, we should remove it in
# the future
i18n.install('heat')
#To ensure messages don't really get translated while running tests.
#As there are lots of places where matching is expected when comparing
#exception message(translated) with raw message.
gettextutils._translate_msgid = fake_translate_msgid
i18n._translate_msgid = fake_translate_msgid

View File

@ -20,6 +20,7 @@ from oslo.config import cfg
import six
from heat.common import exception
from heat.common.i18n import _
from heat.common import short_id
from heat.common import timeutils
from heat.db import api as db_api
@ -32,7 +33,6 @@ from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.engine import template
from heat.openstack.common.gettextutils import _
from heat.tests.common import HeatTestCase
from heat.tests import generic_resource as generic_rsrc
from heat.tests import utils

View File

@ -22,6 +22,7 @@ import mox
from novaclient import exceptions as nova_exceptions
from heat.common import exception
from heat.common.i18n import _
from heat.common import template_format
from heat.db import api as db_api
from heat.engine.clients.os import glance
@ -34,7 +35,6 @@ from heat.engine import resource
from heat.engine.resources import server as servers
from heat.engine import scheduler
from heat.engine import template
from heat.openstack.common.gettextutils import _
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import fakes

View File

@ -18,11 +18,11 @@ import mock
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import parser
from heat.engine.resources.software_config import software_deployment as sd
from heat.engine import rsrc_defn
from heat.engine import template
from heat.openstack.common import gettextutils
from heat.tests.common import HeatTestCase
from heat.tests import utils
@ -687,7 +687,7 @@ class SoftwareDeploymentTest(HeatTestCase):
}, args)
# Test bug 1332355, where details contains a translateable message
details = {'failed': gettextutils.Message('need more memory.')}
details = {'failed': _('need more memory.')}
self.deployment.handle_signal(details)
args = sd.update.call_args[1]
self.assertEqual({