Merge "Deletes the six library and all its usages from manila/utils.py"
This commit is contained in:
commit
7b30e33ebd
|
@ -36,13 +36,11 @@ from oslo_concurrency import lockutils
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import encodeutils
|
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import paramiko
|
import paramiko
|
||||||
import six
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
|
|
||||||
|
@ -287,10 +285,7 @@ def monkey_patch():
|
||||||
# NOTE(vponomaryov): we need to distinguish class methods types
|
# NOTE(vponomaryov): we need to distinguish class methods types
|
||||||
# for py2 and py3, because the concept of 'unbound methods' has
|
# for py2 and py3, because the concept of 'unbound methods' has
|
||||||
# been removed from the python3.x
|
# been removed from the python3.x
|
||||||
if six.PY3:
|
member_type = inspect.isfunction
|
||||||
member_type = inspect.isfunction
|
|
||||||
else:
|
|
||||||
member_type = inspect.ismethod
|
|
||||||
for method, func in inspect.getmembers(clz, member_type):
|
for method, func in inspect.getmembers(clz, member_type):
|
||||||
setattr(
|
setattr(
|
||||||
clz, method,
|
clz, method,
|
||||||
|
@ -368,7 +363,7 @@ def cidr_to_network(cidr):
|
||||||
|
|
||||||
def cidr_to_netmask(cidr):
|
def cidr_to_netmask(cidr):
|
||||||
"""Convert cidr to netmask."""
|
"""Convert cidr to netmask."""
|
||||||
return six.text_type(cidr_to_network(cidr).netmask)
|
return str(cidr_to_network(cidr).netmask)
|
||||||
|
|
||||||
|
|
||||||
def cidr_to_prefixlen(cidr):
|
def cidr_to_prefixlen(cidr):
|
||||||
|
@ -415,7 +410,7 @@ def is_all_tenants(search_opts):
|
||||||
try:
|
try:
|
||||||
all_tenants = strutils.bool_from_string(all_tenants, True)
|
all_tenants = strutils.bool_from_string(all_tenants, True)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
raise exception.InvalidInput(six.text_type(err))
|
raise exception.InvalidInput(str(err))
|
||||||
else:
|
else:
|
||||||
# The empty string is considered enabling all_tenants
|
# The empty string is considered enabling all_tenants
|
||||||
all_tenants = 'all_tenants' in search_opts
|
all_tenants = 'all_tenants' in search_opts
|
||||||
|
@ -579,17 +574,12 @@ def convert_str(text):
|
||||||
|
|
||||||
Convert bytes and Unicode strings to native strings:
|
Convert bytes and Unicode strings to native strings:
|
||||||
|
|
||||||
* convert to bytes on Python 2:
|
|
||||||
encode Unicode using encodeutils.safe_encode()
|
|
||||||
* convert to Unicode on Python 3: decode bytes from UTF-8
|
* convert to Unicode on Python 3: decode bytes from UTF-8
|
||||||
"""
|
"""
|
||||||
if six.PY2:
|
if isinstance(text, bytes):
|
||||||
return encodeutils.safe_encode(text)
|
return text.decode('utf-8')
|
||||||
else:
|
else:
|
||||||
if isinstance(text, bytes):
|
return text
|
||||||
return text.decode('utf-8')
|
|
||||||
else:
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
def translate_string_size_to_float(string, multiplier='G'):
|
def translate_string_size_to_float(string, multiplier='G'):
|
||||||
|
@ -606,7 +596,7 @@ def translate_string_size_to_float(string, multiplier='G'):
|
||||||
- float if correct input data provided
|
- float if correct input data provided
|
||||||
- None if incorrect
|
- None if incorrect
|
||||||
"""
|
"""
|
||||||
if not isinstance(string, six.string_types):
|
if not isinstance(string, str):
|
||||||
return None
|
return None
|
||||||
multipliers = ('K', 'M', 'G', 'T', 'P')
|
multipliers = ('K', 'M', 'G', 'T', 'P')
|
||||||
mapping = {
|
mapping = {
|
||||||
|
|
Loading…
Reference in New Issue