diff options
author | Amrith Kumar <amrith@tesora.com> | 2014-12-09 17:29:24 -0500 |
---|---|---|
committer | Amrith Kumar <amrith@tesora.com> | 2015-01-23 07:49:23 -0500 |
commit | dca7bfe1e6727a347da9b4ad1f7bb7932a2eb134 (patch) | |
tree | 8e60d166ced2ef063867f41ae16268e1edf6e359 | |
parent | 96e44b5a9b7ca3caf6e3a43ec923d2bc49cca563 (diff) | |
download | python-troveclient-dca7bfe1e6727a347da9b4ad1f7bb7932a2eb134.tar.gz |
Handle obsolete and unused oslo modules
The python-troveclient module still had references to strutils, and
gettextutils which are now obsolete.
Change-Id: Ia54a565c00966b0a1cb5f18c6e17e1237b2bfee6
Partial-Bug: #1380789
-rw-r--r-- | openstack-common.conf | 2 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rw-r--r-- | troveclient/client.py | 2 | ||||
-rw-r--r-- | troveclient/compat/utils.py | 2 | ||||
-rw-r--r-- | troveclient/i18n.py | 41 | ||||
-rw-r--r-- | troveclient/shell.py | 16 | ||||
-rw-r--r-- | troveclient/utils.py | 8 |
7 files changed, 58 insertions, 14 deletions
diff --git a/openstack-common.conf b/openstack-common.conf index 5328f0f..feeac2e 100644 --- a/openstack-common.conf +++ b/openstack-common.conf @@ -2,8 +2,6 @@ # The list of modules to copy from openstack-common module=apiclient -module=strutils -module=importutils module=install_venv_common # The base module to hold the copy of openstack.common diff --git a/requirements.txt b/requirements.txt index 1ce2c2b..1cf8ba7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ argparse PrettyTable>=0.7,<0.8 requests>=2.2.0,!=2.4.0 simplejson>=2.2.0 +oslo.utils>=1.2.0 python-keystoneclient>=0.11.1 Babel>=1.3 six>=1.7.0 diff --git a/troveclient/client.py b/troveclient/client.py index 6ef6dbd..f63cab0 100644 --- a/troveclient/client.py +++ b/troveclient/client.py @@ -25,9 +25,9 @@ import logging import requests from keystoneclient import adapter +from oslo.utils import importutils from troveclient.openstack.common.apiclient import client from troveclient.openstack.common.apiclient import exceptions -from troveclient.openstack.common import importutils from troveclient import service_catalog try: diff --git a/troveclient/compat/utils.py b/troveclient/compat/utils.py index 2b21e9e..f4d4d2c 100644 --- a/troveclient/compat/utils.py +++ b/troveclient/compat/utils.py @@ -14,7 +14,7 @@ import os -from troveclient.openstack.common import strutils +from oslo.utils import strutils class HookableMixin(object): diff --git a/troveclient/i18n.py b/troveclient/i18n.py new file mode 100644 index 0000000..f50ac2d --- /dev/null +++ b/troveclient/i18n.py @@ -0,0 +1,41 @@ +# Copyright 2014 Tesora, Inc. +# 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. + +"""oslo.i18n integration module. + +See http://docs.openstack.org/developer/oslo.i18n/usage.html + +""" + +import oslo.i18n + + +# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the +# application name when this module is synced into the separate +# repository. It is OK to have more than one translation function +# using the same domain, since there will still only be one message +# catalog. +_translators = oslo.i18n.TranslatorFactory(domain='python-troveclient') + +# 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/troveclient/shell.py b/troveclient/shell.py index 05e5227..ecdf539 100644 --- a/troveclient/shell.py +++ b/troveclient/shell.py @@ -38,15 +38,17 @@ from keystoneclient.auth.identity.generic import token from keystoneclient.auth.identity import v3 as identity from keystoneclient import session as ks_session +from oslo.utils import encodeutils +from oslo.utils import importutils + import troveclient import troveclient.auth_plugin + from troveclient import client import troveclient.extension +from troveclient.i18n import _ # noqa from troveclient.openstack.common.apiclient import exceptions as exc -from troveclient.openstack.common import gettextutils as gtu -from troveclient.openstack.common.gettextutils import _ # noqa -from troveclient.openstack.common import importutils -from troveclient.openstack.common import strutils + from troveclient import utils from troveclient.v1 import shell as shell_v1 @@ -620,7 +622,7 @@ class OpenStackHelpFormatter(argparse.HelpFormatter): 'trove create <name> <flavor_id> --databases <db_name>' """ if prefix is None: - prefix = gtu._('usage: ') + prefix = _('usage: ') # if usage is specified, use that if usage is not None: @@ -723,7 +725,7 @@ def main(): if sys.version_info >= (3, 0): OpenStackTroveShell().main(sys.argv[1:]) else: - OpenStackTroveShell().main(map(strutils.safe_decode, + OpenStackTroveShell().main(map(encodeutils.safe_decode, sys.argv[1:])) except KeyboardInterrupt: print("... terminating trove client", file=sys.stderr) @@ -733,7 +735,7 @@ def main(): message = six.text_type(e) if not isinstance(message, six.string_types): message = str(message) - print("ERROR: %s" % strutils.safe_encode(message), file=sys.stderr) + print("ERROR: %s" % encodeutils.safe_encode(message), file=sys.stderr) sys.exit(1) diff --git a/troveclient/utils.py b/troveclient/utils.py index 67b600c..1ddbc4d 100644 --- a/troveclient/utils.py +++ b/troveclient/utils.py @@ -24,8 +24,10 @@ import uuid import prettytable import six +from oslo.utils import encodeutils +from oslo.utils import strutils + from troveclient.openstack.common.apiclient import exceptions -from troveclient.openstack.common import strutils def arg(*args, **kwargs): @@ -136,7 +138,7 @@ def _print(pt, order): if sys.version_info >= (3, 0): print(pt.get_string(sortby=order)) else: - print(strutils.safe_encode(pt.get_string(sortby=order))) + print(encodeutils.safe_encode(pt.get_string(sortby=order))) def print_list(objs, fields, formatters={}, order_by=None, obj_is_dict=False, @@ -209,7 +211,7 @@ def find_resource(manager, name_or_id): if isinstance(name_or_id, int) or name_or_id.isdigit(): name_or_id = int(name_or_id) elif sys.version_info <= (3, 0): - name_or_id = strutils.safe_decode(name_or_id) + name_or_id = encodeutils.safe_decode(name_or_id) try: return manager.get(name_or_id) |