Remove openstack.common.strutils

This module now lives in oslo.utils, so import it from there instead.

Co-Authored-By: Ian Cordasco <ian.cordasco@rackspace.com>
Change-Id: Ib35dc840992433542490670781badd9529ec8947
This commit is contained in:
Louis Taylor
2015-01-06 14:32:05 +00:00
parent 363b170851
commit b818826420
14 changed files with 46 additions and 295 deletions
+9 -6
View File
@@ -31,11 +31,12 @@ if os.name == 'nt':
else:
msvcrt = None
from oslo.utils import encodeutils
from oslo.utils import strutils
import prettytable
from glanceclient import exc
from glanceclient.openstack.common import importutils
from glanceclient.openstack.common import strutils
_memoized_property_lock = threading.Lock()
@@ -150,7 +151,7 @@ def print_list(objs, fields, formatters=None, field_settings=None):
row.append(data)
pt.add_row(row)
print(strutils.safe_encode(pt.get_string()))
print(encodeutils.safe_decode(pt.get_string()))
def print_dict(d, max_column_width=80):
@@ -161,7 +162,7 @@ def print_dict(d, max_column_width=80):
if isinstance(v, (dict, list)):
v = json.dumps(v)
pt.add_row([k, v])
print(strutils.safe_encode(pt.get_string(sortby='Property')))
print(encodeutils.safe_decode(pt.get_string(sortby='Property')))
def find_resource(manager, name_or_id):
@@ -175,7 +176,9 @@ def find_resource(manager, name_or_id):
# now try to get entity as uuid
try:
uuid.UUID(strutils.safe_encode(name_or_id))
# This must be unicode for Python 3 compatibility.
# If you pass a bytestring to uuid.UUID, you will get a TypeError
uuid.UUID(encodeutils.safe_decode(name_or_id))
return manager.get(name_or_id)
except (ValueError, exc.NotFound):
pass
@@ -233,7 +236,7 @@ def import_versioned_module(version, submodule=None):
def exit(msg=''):
if msg:
print(strutils.safe_encode(msg), file=sys.stderr)
print(encodeutils.safe_decode(msg), file=sys.stderr)
sys.exit(1)
@@ -291,7 +294,7 @@ def exception_to_str(exc):
except UnicodeError:
error = ("Caught '%(exception)s' exception." %
{"exception": exc.__class__.__name__})
return strutils.safe_encode(error, errors='ignore')
return encodeutils.safe_decode(error, errors='ignore')
def get_file_size(file_obj):