From ef9d5247e9f6fe8592e5e7b75569c02dbbd8251d Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Tue, 8 Jul 2014 18:02:41 +0200 Subject: [PATCH] Switch over oslo.i18n oslo.i18n has recently been released. This patch switches marconi over oslo.i18n. As per oslo.i18n's instructions, a new i18n module has been added under marconi. This module defines the translation globals and imports the necessary functions from oslo.i18n. The patch doesn't change the way Marconi does translation, this means that a `_` function is still being injected to the builtins. Note that the gettextutils module is still a required module from oslo-inc because there are oslo-inc modules that depend on the old gettextutils module. Closes-bug: #1314300 Change-Id: Ifb8f3296d1a0e2483ebd1c8d868b7359ecc99fb5 --- marconi/common/api.py | 2 +- marconi/common/cli.py | 2 +- marconi/common/pipeline.py | 2 +- marconi/common/transport/wsgi/helpers.py | 2 +- marconi/i18n.py | 31 +++++++++++++++++++ marconi/queues/storage/mongodb/messages.py | 2 +- marconi/queues/storage/mongodb/queues.py | 2 +- marconi/queues/storage/mongodb/utils.py | 2 +- marconi/queues/storage/pipeline.py | 2 +- marconi/queues/transport/validation.py | 2 +- marconi/queues/transport/wsgi/driver.py | 2 +- marconi/queues/transport/wsgi/errors.py | 2 +- marconi/queues/transport/wsgi/utils.py | 2 +- marconi/queues/transport/wsgi/v1_0/claims.py | 2 +- .../queues/transport/wsgi/v1_0/messages.py | 2 +- .../queues/transport/wsgi/v1_0/metadata.py | 2 +- marconi/queues/transport/wsgi/v1_0/queues.py | 2 +- marconi/queues/transport/wsgi/v1_0/stats.py | 2 +- marconi/queues/transport/wsgi/v1_1/claims.py | 2 +- .../queues/transport/wsgi/v1_1/messages.py | 2 +- .../queues/transport/wsgi/v1_1/metadata.py | 2 +- marconi/queues/transport/wsgi/v1_1/queues.py | 2 +- marconi/queues/transport/wsgi/v1_1/stats.py | 2 +- requirements-py3.txt | 1 + requirements.txt | 1 + tox.ini | 2 +- 26 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 marconi/i18n.py diff --git a/marconi/common/api.py b/marconi/common/api.py index 079e4b2c3..e8cf8cd4f 100644 --- a/marconi/common/api.py +++ b/marconi/common/api.py @@ -17,7 +17,7 @@ import jsonschema from jsonschema import validators from marconi.common import errors -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ from marconi.openstack.common import log LOG = log.getLogger(__name__) diff --git a/marconi/common/cli.py b/marconi/common/cli.py index 7ceb50071..bb4d4037a 100644 --- a/marconi/common/cli.py +++ b/marconi/common/cli.py @@ -16,7 +16,7 @@ from __future__ import print_function import functools import sys -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ from marconi.openstack.common import log as logging diff --git a/marconi/common/pipeline.py b/marconi/common/pipeline.py index 1b4648c08..78e530ea5 100644 --- a/marconi/common/pipeline.py +++ b/marconi/common/pipeline.py @@ -34,7 +34,7 @@ import contextlib import six from marconi.common import decorators -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging LOG = logging.getLogger(__name__) diff --git a/marconi/common/transport/wsgi/helpers.py b/marconi/common/transport/wsgi/helpers.py index 26d63fb9a..ce350930e 100644 --- a/marconi/common/transport/wsgi/helpers.py +++ b/marconi/common/transport/wsgi/helpers.py @@ -18,7 +18,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.transport import validation diff --git a/marconi/i18n.py b/marconi/i18n.py new file mode 100644 index 000000000..80bafda19 --- /dev/null +++ b/marconi/i18n.py @@ -0,0 +1,31 @@ +# Copyright 2014 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo.i18n import * # noqa + +_translators = TranslatorFactory(domain='marconi') + +# The primary translation function using the well-known name "_" +_ = _translators.primary + +# Translators for log levels. +# +# The abbreviated names are meant to reflect the usual use of a short +# name like '_'. The "L" is for "log" and the other letter comes from +# the level. +_LI = _translators.log_info +_LW = _translators.log_warning +_LE = _translators.log_error +_LC = _translators.log_critical diff --git a/marconi/queues/storage/mongodb/messages.py b/marconi/queues/storage/mongodb/messages.py index 011e57105..b6f5715e1 100644 --- a/marconi/queues/storage/mongodb/messages.py +++ b/marconi/queues/storage/mongodb/messages.py @@ -28,7 +28,7 @@ from bson import objectid import pymongo.errors import pymongo.read_preferences -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.openstack.common import timeutils from marconi.queues import storage diff --git a/marconi/queues/storage/mongodb/queues.py b/marconi/queues/storage/mongodb/queues.py index b899ee870..1e7ab7dae 100644 --- a/marconi/queues/storage/mongodb/queues.py +++ b/marconi/queues/storage/mongodb/queues.py @@ -24,7 +24,7 @@ Field Mappings: import pymongo.errors from marconi.common import decorators -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.openstack.common import timeutils from marconi.queues import storage diff --git a/marconi/queues/storage/mongodb/utils.py b/marconi/queues/storage/mongodb/utils.py index 66cf7e098..234ee42b3 100644 --- a/marconi/queues/storage/mongodb/utils.py +++ b/marconi/queues/storage/mongodb/utils.py @@ -26,7 +26,7 @@ from bson import objectid from bson import tz_util from pymongo import errors -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.openstack.common import timeutils from marconi.queues.storage import errors as storage_errors diff --git a/marconi/queues/storage/pipeline.py b/marconi/queues/storage/pipeline.py index ad763d0d5..1ce8e51a2 100644 --- a/marconi/queues/storage/pipeline.py +++ b/marconi/queues/storage/pipeline.py @@ -17,7 +17,7 @@ from stevedore import driver from marconi import common from marconi.common import decorators -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ from marconi.openstack.common import log as logging from marconi.queues.storage import base diff --git a/marconi/queues/transport/validation.py b/marconi/queues/transport/validation.py index eb3b302a0..9131e47d9 100644 --- a/marconi/queues/transport/validation.py +++ b/marconi/queues/transport/validation.py @@ -17,7 +17,7 @@ import re from oslo.config import cfg -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ MIN_MESSAGE_TTL = 60 MIN_CLAIM_TTL = 60 diff --git a/marconi/queues/transport/wsgi/driver.py b/marconi/queues/transport/wsgi/driver.py index ce4a310d6..a037755b4 100644 --- a/marconi/queues/transport/wsgi/driver.py +++ b/marconi/queues/transport/wsgi/driver.py @@ -21,7 +21,7 @@ from oslo.config import cfg from marconi.common import decorators from marconi.common.transport.wsgi import helpers -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues import transport from marconi.queues.transport import auth diff --git a/marconi/queues/transport/wsgi/errors.py b/marconi/queues/transport/wsgi/errors.py index 051b6da69..7fbde2ad8 100644 --- a/marconi/queues/transport/wsgi/errors.py +++ b/marconi/queues/transport/wsgi/errors.py @@ -15,7 +15,7 @@ import falcon -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ class HTTPServiceUnavailable(falcon.HTTPServiceUnavailable): diff --git a/marconi/queues/transport/wsgi/utils.py b/marconi/queues/transport/wsgi/utils.py index e6111feaf..1d61fd3e2 100644 --- a/marconi/queues/transport/wsgi/utils.py +++ b/marconi/queues/transport/wsgi/utils.py @@ -14,7 +14,7 @@ import uuid -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.transport import utils from marconi.queues.transport.wsgi import errors diff --git a/marconi/queues/transport/wsgi/v1_0/claims.py b/marconi/queues/transport/wsgi/v1_0/claims.py index ea93d5f4b..2d305597b 100644 --- a/marconi/queues/transport/wsgi/v1_0/claims.py +++ b/marconi/queues/transport/wsgi/v1_0/claims.py @@ -16,7 +16,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.storage import errors as storage_errors from marconi.queues.transport import utils diff --git a/marconi/queues/transport/wsgi/v1_0/messages.py b/marconi/queues/transport/wsgi/v1_0/messages.py index 5f40c8f0d..29fa3ab8a 100644 --- a/marconi/queues/transport/wsgi/v1_0/messages.py +++ b/marconi/queues/transport/wsgi/v1_0/messages.py @@ -16,7 +16,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.storage import errors as storage_errors from marconi.queues.transport import utils diff --git a/marconi/queues/transport/wsgi/v1_0/metadata.py b/marconi/queues/transport/wsgi/v1_0/metadata.py index 608edf1b3..df6457853 100644 --- a/marconi/queues/transport/wsgi/v1_0/metadata.py +++ b/marconi/queues/transport/wsgi/v1_0/metadata.py @@ -16,7 +16,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.storage import errors as storage_errors from marconi.queues.transport import utils diff --git a/marconi/queues/transport/wsgi/v1_0/queues.py b/marconi/queues/transport/wsgi/v1_0/queues.py index bdf3f0d72..3bac09285 100644 --- a/marconi/queues/transport/wsgi/v1_0/queues.py +++ b/marconi/queues/transport/wsgi/v1_0/queues.py @@ -16,7 +16,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.transport import utils from marconi.queues.transport import validation diff --git a/marconi/queues/transport/wsgi/v1_0/stats.py b/marconi/queues/transport/wsgi/v1_0/stats.py index 9d80afb74..704dde370 100644 --- a/marconi/queues/transport/wsgi/v1_0/stats.py +++ b/marconi/queues/transport/wsgi/v1_0/stats.py @@ -15,7 +15,7 @@ import falcon -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.storage import errors as storage_errors from marconi.queues.transport import utils diff --git a/marconi/queues/transport/wsgi/v1_1/claims.py b/marconi/queues/transport/wsgi/v1_1/claims.py index ea93d5f4b..2d305597b 100644 --- a/marconi/queues/transport/wsgi/v1_1/claims.py +++ b/marconi/queues/transport/wsgi/v1_1/claims.py @@ -16,7 +16,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.storage import errors as storage_errors from marconi.queues.transport import utils diff --git a/marconi/queues/transport/wsgi/v1_1/messages.py b/marconi/queues/transport/wsgi/v1_1/messages.py index 853d1749c..52c29f4ce 100644 --- a/marconi/queues/transport/wsgi/v1_1/messages.py +++ b/marconi/queues/transport/wsgi/v1_1/messages.py @@ -16,7 +16,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.storage import errors as storage_errors from marconi.queues.transport import utils diff --git a/marconi/queues/transport/wsgi/v1_1/metadata.py b/marconi/queues/transport/wsgi/v1_1/metadata.py index 608edf1b3..df6457853 100644 --- a/marconi/queues/transport/wsgi/v1_1/metadata.py +++ b/marconi/queues/transport/wsgi/v1_1/metadata.py @@ -16,7 +16,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.storage import errors as storage_errors from marconi.queues.transport import utils diff --git a/marconi/queues/transport/wsgi/v1_1/queues.py b/marconi/queues/transport/wsgi/v1_1/queues.py index bdf3f0d72..3bac09285 100644 --- a/marconi/queues/transport/wsgi/v1_1/queues.py +++ b/marconi/queues/transport/wsgi/v1_1/queues.py @@ -16,7 +16,7 @@ import falcon import six -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.transport import utils from marconi.queues.transport import validation diff --git a/marconi/queues/transport/wsgi/v1_1/stats.py b/marconi/queues/transport/wsgi/v1_1/stats.py index d1f313744..b9e995b4c 100644 --- a/marconi/queues/transport/wsgi/v1_1/stats.py +++ b/marconi/queues/transport/wsgi/v1_1/stats.py @@ -15,7 +15,7 @@ import falcon -from marconi.openstack.common.gettextutils import _ +from marconi.i18n import _ import marconi.openstack.common.log as logging from marconi.queues.storage import errors as storage_errors from marconi.queues.transport import utils diff --git a/requirements-py3.txt b/requirements-py3.txt index 2f4b834fc..f31ca5939 100644 --- a/requirements-py3.txt +++ b/requirements-py3.txt @@ -15,4 +15,5 @@ WebOb>=1.2.3 stevedore>=0.14 six>=1.7.0 oslo.config>=1.2.1 +oslo.i18n>=0.1.0 SQLAlchemy>=0.7.8,!=0.9.5,<=0.9.99 diff --git a/requirements.txt b/requirements.txt index c07558403..2de6489e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,4 +14,5 @@ WebOb>=1.2.3 stevedore>=0.14 six>=1.7.0 oslo.config>=1.2.1 +oslo.i18n>=0.1.0 SQLAlchemy>=0.7.8,!=0.9.5,<=0.9.99 diff --git a/tox.ini b/tox.ini index 96701abeb..4a055d205 100644 --- a/tox.ini +++ b/tox.ini @@ -52,5 +52,5 @@ commands = python setup.py build_sphinx exclude = .venv*,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*.egg,.update-venv [hacking] -import_exceptions = marconi.openstack.common.gettextutils._ +import_exceptions = marconi.openstack.common.gettextutils._,marconi.i18n._