From cf73a8fb7f82688ffd6fd56bb1a0a69a82dfccf7 Mon Sep 17 00:00:00 2001 From: Jim Rollenhagen Date: Wed, 30 Sep 2015 08:19:43 -0700 Subject: [PATCH] Move to oslo.i18n This brings in i18n.py from ironic (as a helper) and switches all i18n references to use that module. The _i18n module from oslo-incubator is left, as syncing imageutils brings it in. Change-Id: I012ceb7031695407febbb3bbd24622773a2d9d0f --- ironic_lib/common/__init__.py | 0 ironic_lib/common/i18n.py | 31 +++++++++++++++++++++++++++++++ ironic_lib/disk_partitioner.py | 4 ++-- ironic_lib/disk_utils.py | 6 +++--- ironic_lib/exception.py | 4 ++-- ironic_lib/utils.py | 4 ++-- requirements.txt | 1 + 7 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 ironic_lib/common/__init__.py create mode 100644 ironic_lib/common/i18n.py diff --git a/ironic_lib/common/__init__.py b/ironic_lib/common/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ironic_lib/common/i18n.py b/ironic_lib/common/i18n.py new file mode 100644 index 00000000..0537acb0 --- /dev/null +++ b/ironic_lib/common/i18n.py @@ -0,0 +1,31 @@ +# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. +# 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. + +import oslo_i18n as i18n + +_translators = i18n.TranslatorFactory(domain='ironic-lib') + +# 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/ironic_lib/disk_partitioner.py b/ironic_lib/disk_partitioner.py index 5890a59b..a1efff60 100644 --- a/ironic_lib/disk_partitioner.py +++ b/ironic_lib/disk_partitioner.py @@ -20,9 +20,9 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_service import loopingcall +from ironic_lib.common.i18n import _ +from ironic_lib.common.i18n import _LW from ironic_lib import exception -from ironic_lib.openstack.common._i18n import _ -from ironic_lib.openstack.common._i18n import _LW from ironic_lib import utils diff --git a/ironic_lib/disk_utils.py b/ironic_lib/disk_utils.py index 6822a4c2..3a71414c 100644 --- a/ironic_lib/disk_utils.py +++ b/ironic_lib/disk_utils.py @@ -31,11 +31,11 @@ from oslo_config import cfg from oslo_utils import excutils from oslo_utils import units -from ironic_lib.openstack.common._i18n import _ -from ironic_lib.openstack.common._i18n import _LE -from ironic_lib.openstack.common._i18n import _LW from ironic_lib.openstack.common import imageutils +from ironic_lib.common.i18n import _ +from ironic_lib.common.i18n import _LE +from ironic_lib.common.i18n import _LW from ironic_lib import disk_partitioner from ironic_lib import exception from ironic_lib import utils diff --git a/ironic_lib/exception.py b/ironic_lib/exception.py index b43a4248..76ea2372 100644 --- a/ironic_lib/exception.py +++ b/ironic_lib/exception.py @@ -27,8 +27,8 @@ import six from oslo_config import cfg -from ironic_lib.openstack.common._i18n import _ -from ironic_lib.openstack.common._i18n import _LE +from ironic_lib.common.i18n import _ +from ironic_lib.common.i18n import _LE LOG = logging.getLogger(__name__) diff --git a/ironic_lib/utils.py b/ironic_lib/utils.py index 14f99775..6f3d73dd 100644 --- a/ironic_lib/utils.py +++ b/ironic_lib/utils.py @@ -27,9 +27,9 @@ from oslo_concurrency import processutils from oslo_config import cfg from oslo_utils import excutils +from ironic_lib.common.i18n import _LE +from ironic_lib.common.i18n import _LW from ironic_lib import exception -from ironic_lib.openstack.common._i18n import _LE -from ironic_lib.openstack.common._i18n import _LW utils_opts = [ cfg.StrOpt('rootwrap_config', diff --git a/requirements.txt b/requirements.txt index bad9c5e8..b21a88ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ greenlet>=0.3.2 Jinja2>=2.6 # BSD License (3 clause) oslo.concurrency>=2.3.0 # Apache-2.0 oslo.config>=2.3.0 # Apache-2.0 +oslo.i18n>=1.5.0 # Apache-2.0 oslo.middleware>=2.8.0 # Apache-2.0 oslo.serialization>=1.4.0 # Apache-2.0 oslo.service>=0.7.0 # Apache-2.0