Use _i18n instead of i18n

It is suggested to use _i18n.py per oslo.i18n document.
http://docs.openstack.org/developer/oslo.i18n/usage.html

neutronclient.i18n is now a wrapper module which emits
the derecation warning. It is because might be used in
implementation of the client extensions in other repositories.

Closes-Bug: #1519493
Change-Id: I44969daeedc9a66dd9ad5bf80617516faf245ecc
This commit is contained in:
Akihiro Motoki 2015-11-28 09:16:42 +09:00
parent 31d55759e5
commit 787ba9250b
50 changed files with 101 additions and 60 deletions

41
neutronclient/_i18n.py Normal file
View File

@ -0,0 +1,41 @@
# 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.
import oslo_i18n
DOMAIN = 'neutronclient'
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# The primary translation function using the well-known name "_"
_ = _translators.primary
# The contextual translation function using the name "_C"
_C = _translators.contextual_form
# The plural translation function using the name "_P"
_P = _translators.plural_form
# 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
def get_available_languages():
return oslo_i18n.get_available_languages(DOMAIN)

View File

@ -25,9 +25,9 @@ from keystoneauth1 import access
from keystoneauth1 import adapter from keystoneauth1 import adapter
import requests import requests
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutronclient.i18n import _ from neutronclient._i18n import _
""" """
Neutron base exception handling. Neutron base exception handling.

View File

@ -18,8 +18,8 @@ import logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six import six
from neutronclient._i18n import _
from neutronclient.common import exceptions as exception from neutronclient.common import exceptions as exception
from neutronclient.i18n import _
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -26,8 +26,8 @@ from oslo_utils import encodeutils
from oslo_utils import importutils from oslo_utils import importutils
import six import six
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.i18n import _
def env(*vars, **kwargs): def env(*vars, **kwargs):

View File

@ -15,8 +15,8 @@
import netaddr import netaddr
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.i18n import _
def validate_int_range(parsed_args, attr_name, min_value=None, max_value=None): def validate_int_range(parsed_args, attr_name, min_value=None, max_value=None):

View File

@ -10,19 +10,18 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import oslo_i18n as i18n # TODO(amotoki): Remove this file at the beginning of Nxx cycle.
_translators = i18n.TranslatorFactory(domain='neutronclient') from debtcollector import moves
# The primary translation function using the well-known name "_" from neutronclient import _i18n
_ = _translators.primary
# Translators for log levels. message = ("moved to neutronclient._i18n; please migrate to local "
# "oslo_i18n usage, as defined at "
# The abbreviated names are meant to reflect the usual use of a short "http://docs.openstack.org/developer/oslo.i18n/usage.html")
# name like '_'. The "L" is for "log" and the other letter comes from
# the level. _ = moves.moved_function(_i18n._, '_', __name__, message=message)
_LI = _translators.log_info _LC = moves.moved_function(_i18n._LC, '_LC', __name__, message=message)
_LW = _translators.log_warning _LE = moves.moved_function(_i18n._LE, '_LE', __name__, message=message)
_LE = _translators.log_error _LW = moves.moved_function(_i18n._LW, '_LW', __name__, message=message)
_LC = _translators.log_critical _LI = moves.moved_function(_i18n._LI, '_LI', __name__, message=message)

View File

@ -27,10 +27,10 @@ from cliff import show
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six import six
from neutronclient._i18n import _
from neutronclient.common import command from neutronclient.common import command
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
HEX_ELEM = '[0-9A-Fa-f]' HEX_ELEM = '[0-9A-Fa-f]'
UUID_PATTERN = '-'.join([HEX_ELEM + '{8}', HEX_ELEM + '{4}', UUID_PATTERN = '-'.join([HEX_ELEM + '{8}', HEX_ELEM + '{4}',

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -16,7 +16,7 @@
from __future__ import print_function from __future__ import print_function
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0 import network from neutronclient.neutron.v2_0 import network
from neutronclient.neutron.v2_0 import router from neutronclient.neutron.v2_0 import router

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
# #
from neutronclient._i18n import _
from neutronclient.common import extension from neutronclient.common import extension
from neutronclient.i18n import _
def _add_updatable_args(parser): def _add_updatable_args(parser):

View File

@ -17,8 +17,8 @@ from __future__ import print_function
import argparse import argparse
from neutronclient._i18n import _
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -15,8 +15,8 @@
import argparse import argparse
from neutronclient._i18n import _
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -18,7 +18,7 @@ from __future__ import print_function
import argparse import argparse
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20

View File

@ -18,7 +18,7 @@ from __future__ import print_function
import argparse import argparse
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20

View File

@ -16,8 +16,8 @@
import argparse import argparse
from neutronclient._i18n import _
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20

View File

@ -16,7 +16,7 @@
from __future__ import print_function from __future__ import print_function
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -17,7 +17,7 @@
import six import six
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -15,7 +15,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -15,8 +15,8 @@
# under the License. # under the License.
# #
from neutronclient._i18n import _
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -15,7 +15,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -16,7 +16,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -16,8 +16,8 @@
# under the License. # under the License.
# #
from neutronclient._i18n import _
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20

View File

@ -16,9 +16,9 @@
import argparse import argparse
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0 import availability_zone from neutronclient.neutron.v2_0 import availability_zone
from neutronclient.neutron.v2_0.qos import policy as qos_policy from neutronclient.neutron.v2_0.qos import policy as qos_policy

View File

@ -16,8 +16,8 @@
from __future__ import print_function from __future__ import print_function
from neutronclient._i18n import _
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20
GW_RESOURCE = 'network_gateway' GW_RESOURCE = 'network_gateway'

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -18,9 +18,9 @@ import argparse
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0.qos import policy as qos_policy from neutronclient.neutron.v2_0.qos import policy as qos_policy

View File

@ -15,8 +15,8 @@
# #
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.neutron.v2_0.qos import rule as qos_rule from neutronclient.neutron.v2_0.qos import rule as qos_rule

View File

@ -16,7 +16,7 @@
import os import os
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20

View File

@ -15,7 +15,7 @@
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.neutron.v2_0.qos import policy as qos_policy from neutronclient.neutron.v2_0.qos import policy as qos_policy

View File

@ -23,9 +23,9 @@ from cliff import show
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six import six
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -20,9 +20,9 @@ import argparse
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0 import availability_zone from neutronclient.neutron.v2_0 import availability_zone

View File

@ -16,8 +16,8 @@
import argparse import argparse
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -18,9 +18,9 @@ import argparse
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.neutron import v2_0 as neutronV20

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
# #
from neutronclient._i18n import _
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.neutron.v2_0.vpn import utils as vpn_utils from neutronclient.neutron.v2_0.vpn import utils as vpn_utils

View File

@ -16,9 +16,9 @@
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.neutron.v2_0.vpn import utils as vpn_utils from neutronclient.neutron.v2_0.vpn import utils as vpn_utils

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
# #
from neutronclient._i18n import _
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.neutron.v2_0.vpn import utils as vpn_utils from neutronclient.neutron.v2_0.vpn import utils as vpn_utils

View File

@ -18,8 +18,8 @@
"""VPN Utilities and helper functions.""" """VPN Utilities and helper functions."""
from neutronclient._i18n import _
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.i18n import _
dpd_supported_actions = ['hold', 'clear', 'restart', dpd_supported_actions = ['hold', 'clear', 'restart',
'restart-by-peer', 'disabled'] 'restart-by-peer', 'disabled']

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from neutronclient.i18n import _ from neutronclient._i18n import _
from neutronclient.neutron import v2_0 as neutronv20 from neutronclient.neutron import v2_0 as neutronv20

View File

@ -34,12 +34,12 @@ from oslo_utils import encodeutils
from cliff import app from cliff import app
from cliff import commandmanager from cliff import commandmanager
from neutronclient._i18n import _
from neutronclient.common import clientmanager from neutronclient.common import clientmanager
from neutronclient.common import command as openstack_command from neutronclient.common import command as openstack_command
from neutronclient.common import exceptions as exc from neutronclient.common import exceptions as exc
from neutronclient.common import extension as client_extension from neutronclient.common import extension as client_extension
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
from neutronclient.neutron.v2_0 import address_scope from neutronclient.neutron.v2_0 import address_scope
from neutronclient.neutron.v2_0 import agent from neutronclient.neutron.v2_0 import agent
from neutronclient.neutron.v2_0 import agentscheduler from neutronclient.neutron.v2_0 import agentscheduler

View File

@ -23,12 +23,12 @@ import time
import requests import requests
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
from neutronclient._i18n import _
from neutronclient import client from neutronclient import client
from neutronclient.common import exceptions from neutronclient.common import exceptions
from neutronclient.common import extension as client_extension from neutronclient.common import extension as client_extension
from neutronclient.common import serializer from neutronclient.common import serializer
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.i18n import _
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)

View File

@ -4,6 +4,7 @@
pbr>=1.6 pbr>=1.6
argparse argparse
cliff>=1.15.0 # Apache-2.0 cliff>=1.15.0 # Apache-2.0
debtcollector>=0.3.0 # Apache-2.0
iso8601>=0.1.9 iso8601>=0.1.9
netaddr!=0.7.16,>=0.7.12 netaddr!=0.7.16,>=0.7.12
oslo.i18n>=1.5.0 # Apache-2.0 oslo.i18n>=1.5.0 # Apache-2.0