Remove gettext magic and import _ explicitly

Instead of magically loading `_` into python built-in globals, import it
explicitly where needed.

Partially-implements: py3k-support
Change-Id: Icfedf9f86ead81bbee038506a91c456907af0d05
This commit is contained in:
Flavio Percoco 2013-12-05 00:45:54 +01:00
parent ec18885d96
commit eef012d4c4
19 changed files with 23 additions and 4 deletions

View File

@ -20,8 +20,6 @@ try:
_sys.stderr.write('Running from marconi source directory.\n') _sys.stderr.write('Running from marconi source directory.\n')
del _sys del _sys
except NameError: except NameError:
import gettext
gettext.install('marconi', unicode=1)
import marconi.queues.bootstrap import marconi.queues.bootstrap
Bootstrap = marconi.queues.bootstrap.Bootstrap Bootstrap = marconi.queues.bootstrap.Bootstrap

View File

@ -17,6 +17,7 @@ import jsonschema
from jsonschema import validators from jsonschema import validators
from marconi.common import errors from marconi.common import errors
from marconi.openstack.common.gettextutils import _
from marconi.openstack.common import log from marconi.openstack.common import log
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)

View File

@ -21,6 +21,7 @@ import os
import sys import sys
import termios import termios
from marconi.openstack.common.gettextutils import _
from marconi.openstack.common import log as logging from marconi.openstack.common import log as logging

View File

@ -33,6 +33,7 @@ them do, an AttributeError exception will be raised.
import six import six
from marconi.common import decorators from marconi.common import decorators
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,6 +17,7 @@
import falcon import falcon
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.queues.transport import validation from marconi.queues.transport import validation

View File

@ -19,6 +19,7 @@ from stevedore import driver
from marconi.common.cache import cache as oslo_cache from marconi.common.cache import cache as oslo_cache
from marconi.common import decorators from marconi.common import decorators
from marconi.common import errors from marconi.common import errors
from marconi.openstack.common.gettextutils import _
from marconi.openstack.common import log from marconi.openstack.common import log
from marconi.queues.storage import pipeline from marconi.queues.storage import pipeline
from marconi.queues.storage import sharding from marconi.queues.storage import sharding

View File

@ -27,6 +27,7 @@ import time
import pymongo.errors import pymongo.errors
import pymongo.read_preferences import pymongo.read_preferences
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.openstack.common import timeutils from marconi.openstack.common import timeutils
from marconi.queues import storage from marconi.queues import storage

View File

@ -23,6 +23,7 @@ Field Mappings:
import pymongo.errors import pymongo.errors
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.openstack.common import timeutils from marconi.openstack.common import timeutils
from marconi.queues import storage from marconi.queues import storage

View File

@ -19,6 +19,7 @@ from stevedore import driver
from marconi import common from marconi import common
from marconi.common import decorators from marconi.common import decorators
from marconi.openstack.common.gettextutils import _
from marconi.openstack.common import log as logging from marconi.openstack.common import log as logging
from marconi.queues.storage import base from marconi.queues.storage import base

View File

@ -17,6 +17,7 @@
from keystoneclient.middleware import auth_token from keystoneclient.middleware import auth_token
from marconi.openstack.common.gettextutils import _
from marconi.openstack.common import log from marconi.openstack.common import log
@ -40,7 +41,7 @@ class KeystoneAuth(object):
@classmethod @classmethod
def install(cls, app, conf): def install(cls, app, conf):
"""Install Auth check on application.""" """Install Auth check on application."""
LOG.debug(_(u"Installing Keystone's auth protocol")) LOG.debug(_(u'Installing Keystone\'s auth protocol'))
cls._register_opts(conf) cls._register_opts(conf)
conf = dict(conf.get(cls.OPT_GROUP_NAME)) conf = dict(conf.get(cls.OPT_GROUP_NAME))
return auth_token.AuthProtocol(app, conf=conf) return auth_token.AuthProtocol(app, conf=conf)

View File

@ -16,6 +16,7 @@
import falcon import falcon
import six import six
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils from marconi.queues.transport import utils

View File

@ -24,6 +24,7 @@ import six
from marconi.common import decorators from marconi.common import decorators
from marconi.common.transport import version from marconi.common.transport import version
from marconi.common.transport.wsgi import helpers from marconi.common.transport.wsgi import helpers
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.queues import transport from marconi.queues import transport
from marconi.queues.transport import auth, validation from marconi.queues.transport import auth, validation

View File

@ -15,6 +15,8 @@
import falcon import falcon
from marconi.openstack.common.gettextutils import _
class HTTPServiceUnavailable(falcon.HTTPServiceUnavailable): class HTTPServiceUnavailable(falcon.HTTPServiceUnavailable):
"""Wraps falcon.HTTPServiceUnavailable with Marconi messaging.""" """Wraps falcon.HTTPServiceUnavailable with Marconi messaging."""

View File

@ -16,6 +16,7 @@
import falcon import falcon
import six import six
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils from marconi.queues.transport import utils

View File

@ -16,6 +16,7 @@
import falcon import falcon
import six import six
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils from marconi.queues.transport import utils

View File

@ -16,6 +16,7 @@
import falcon import falcon
import six import six
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.queues.transport import utils from marconi.queues.transport import utils
from marconi.queues.transport import validation from marconi.queues.transport import validation

View File

@ -15,6 +15,7 @@
import falcon import falcon
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils from marconi.queues.transport import utils

View File

@ -16,6 +16,7 @@
import uuid import uuid
from marconi.openstack.common.gettextutils import _
import marconi.openstack.common.log as logging import marconi.openstack.common.log as logging
from marconi.queues.transport import utils from marconi.queues.transport import utils
from marconi.queues.transport.wsgi import errors from marconi.queues.transport.wsgi import errors

View File

@ -31,5 +31,8 @@ setenv = NOSE_WITH_COVERAGE=1
commands = {posargs} commands = {posargs}
[flake8] [flake8]
builtins = _,__MARCONI_SETUP__ builtins = __MARCONI_SETUP__
exclude = .venv*,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*.egg,.update-venv exclude = .venv*,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*.egg,.update-venv
[hacking]
import_exceptions = marconi.openstack.common.gettextutils._