Remove the monkey patching of _ into the builtins
Previous _ was monkey patched into builtins whenever certain modules were imported. This removes that and simply imports it when it is needed. Change-Id: I0af2c6d8a230e94440d655d13cab9107ac20d13c
This commit is contained in:
parent
1a024a0777
commit
1bebb3feaf
|
@ -19,16 +19,6 @@ If you do not follow the project conventions, your code may cause the
|
|||
LocalizationTestCase.test_multiple_positional_format_placeholders test to fail
|
||||
in nova/tests/test_localization.py.
|
||||
|
||||
The ``_()`` function is brought into the global scope by doing::
|
||||
The ``_()`` function is found by doing::
|
||||
|
||||
from nova.openstack.common import gettextutils
|
||||
gettextutils.install('nova')
|
||||
|
||||
These lines are needed in any toplevel script before any nova modules are
|
||||
imported. If this code is missing, it may result in an error that looks like::
|
||||
|
||||
NameError: name '_' is not defined
|
||||
|
||||
The gettextutils.install() function also queries the NOVA_LOCALEDIR environment
|
||||
variable to allow overriding the default localedir with a specific custom
|
||||
location for Nova's message catalog.
|
||||
from nova.openstack.common.gettextutils import _
|
||||
|
|
|
@ -20,6 +20,7 @@ import re
|
|||
from oslo.config import cfg
|
||||
|
||||
from nova import exception
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.virt import driver
|
||||
|
||||
|
|
|
@ -32,6 +32,3 @@ os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
|
|||
import eventlet
|
||||
|
||||
eventlet.monkey_patch(os=False)
|
||||
|
||||
from nova.openstack.common import gettextutils
|
||||
gettextutils.install('nova')
|
||||
|
|
|
@ -31,6 +31,7 @@ from oslo.config import cfg
|
|||
import webob.exc
|
||||
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import safe_utils
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ Filter support
|
|||
"""
|
||||
|
||||
from nova import loadables
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -58,6 +58,7 @@ from oslo.config import cfg
|
|||
from nova import baserpc
|
||||
from nova.db import base
|
||||
from nova.objects import base as objects_base
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import periodic_task
|
||||
from nova.openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||
|
|
|
@ -30,6 +30,7 @@ from nova.image import glance
|
|||
from nova import network
|
||||
from nova.network import model as network_model
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log
|
||||
from nova.openstack.common.notifier import api as notifier_api
|
||||
from nova.openstack.common import timeutils
|
||||
|
|
|
@ -29,10 +29,8 @@ import textwrap
|
|||
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova.openstack.common import gettextutils
|
||||
from nova.openstack.common import importutils
|
||||
|
||||
gettextutils.install('nova')
|
||||
|
||||
STROPT = "StrOpt"
|
||||
BOOLOPT = "BoolOpt"
|
||||
|
|
|
@ -22,6 +22,7 @@ import os.path
|
|||
from oslo.config import cfg
|
||||
|
||||
from nova import exception
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import policy
|
||||
from nova import utils
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ from oslo.config import cfg
|
|||
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import importutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import timeutils
|
||||
|
|
|
@ -27,6 +27,7 @@ from oslo.config import cfg
|
|||
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova import exception
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.scheduler import driver
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
|
|
@ -31,6 +31,7 @@ from nova.conductor import api as conductor_api
|
|||
from nova import db
|
||||
from nova import exception
|
||||
from nova import notifications
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import importutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common.notifier import api as notifier
|
||||
|
|
|
@ -27,6 +27,7 @@ from nova.compute import flavors
|
|||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common.notifier import api as notifier
|
||||
from nova.scheduler import driver
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
import netaddr
|
||||
|
||||
from nova.compute import api as compute
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# under the License.
|
||||
|
||||
from nova import db
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
from nova.scheduler.filters import extra_specs_ops
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from nova import db
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
from nova.scheduler.filters import extra_specs_ops
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
from nova import servicegroup
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
from oslo.config import cfg
|
||||
|
||||
from nova import db
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
from oslo.config import cfg
|
||||
|
||||
from nova import db
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import filters
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ from oslo.config import cfg
|
|||
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import timeutils
|
||||
|
|
|
@ -25,6 +25,7 @@ from nova.compute import task_states
|
|||
from nova.compute import vm_states
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import timeutils
|
||||
from nova.scheduler import filters
|
||||
|
|
|
@ -29,6 +29,7 @@ import os
|
|||
from oslo.config import cfg
|
||||
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import timeutils
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ from nova.compute import flavors
|
|||
from nova.compute import utils as compute_utils
|
||||
from nova import db
|
||||
from nova import notifications
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common.notifier import api as notifier
|
||||
|
|
|
@ -28,6 +28,7 @@ from oslo.config import cfg
|
|||
from nova import conductor
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import importutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import rpc
|
||||
|
|
|
@ -43,8 +43,3 @@ os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
|
|||
import eventlet
|
||||
|
||||
eventlet.monkey_patch(os=False)
|
||||
|
||||
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
||||
# The code below enables nosetests to work with i18n _() blocks
|
||||
import __builtin__
|
||||
setattr(__builtin__, '_', lambda x: x)
|
||||
|
|
|
@ -43,6 +43,7 @@ from oslo.config import cfg
|
|||
|
||||
from nova import exception
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import importutils
|
||||
from nova.openstack.common import lockutils
|
||||
from nova.openstack.common import log as logging
|
||||
|
|
|
@ -35,6 +35,7 @@ import webob.exc
|
|||
|
||||
from nova import exception
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
|
||||
# Raise the default from 8192 to accommodate large tokens
|
||||
|
|
1
tox.ini
1
tox.ini
|
@ -48,7 +48,6 @@ commands = {posargs}
|
|||
# H501 Do not use locals() for string formatting
|
||||
|
||||
ignore = E121,E122,E123,E124,E126,E127,E128,E711,E712,H102,H232,H233,H302,H303,H404,F403,H501,F811,F841,N309
|
||||
builtins = _
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,*plugins/xenserver*,tools
|
||||
|
||||
[hacking]
|
||||
|
|
Loading…
Reference in New Issue