Remove six
Replace the following items with Python 3 style code: - six.text_type - six.StringIO Change-Id: I9db56ea304938d66753106357e572f307d226850
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import ast
|
import ast
|
||||||
import logging
|
import logging
|
||||||
import six
|
|
||||||
|
|
||||||
from cliff import command
|
from cliff import command
|
||||||
from cliff.formatters import table
|
from cliff.formatters import table
|
||||||
@@ -90,7 +89,7 @@ class BlazarCommand(OpenStackCommand):
|
|||||||
|
|
||||||
def format_output_data(self, data):
|
def format_output_data(self, data):
|
||||||
for k, v in data.items():
|
for k, v in data.items():
|
||||||
if isinstance(v, six.text_type):
|
if isinstance(v, str):
|
||||||
try:
|
try:
|
||||||
# Deserialize if possible into dict, lists, tuples...
|
# Deserialize if possible into dict, lists, tuples...
|
||||||
v = ast.literal_eval(v)
|
v = ast.literal_eval(v)
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ from cliff import app
|
|||||||
from cliff import commandmanager
|
from cliff import commandmanager
|
||||||
from keystoneauth1 import loading
|
from keystoneauth1 import loading
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from blazarclient import client as blazar_client
|
from blazarclient import client as blazar_client
|
||||||
from blazarclient import exception
|
from blazarclient import exception
|
||||||
@@ -265,10 +264,10 @@ class BlazarShell(app.App):
|
|||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
if self.options.debug:
|
if self.options.debug:
|
||||||
self.log.exception(six.text_type(err))
|
self.log.exception(str(err))
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
self.log.error(six.text_type(err))
|
self.log.error(str(err))
|
||||||
return 1
|
return 1
|
||||||
if self.interactive_mode:
|
if self.interactive_mode:
|
||||||
_argv = [sys.argv[0]]
|
_argv = [sys.argv[0]]
|
||||||
@@ -291,17 +290,17 @@ class BlazarShell(app.App):
|
|||||||
return run_command(cmd, cmd_parser, sub_argv)
|
return run_command(cmd, cmd_parser, sub_argv)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
if self.options.debug:
|
if self.options.debug:
|
||||||
self.log.exception(six.text_type(err))
|
self.log.exception(str(err))
|
||||||
else:
|
else:
|
||||||
self.log.error(six.text_type(err))
|
self.log.error(str(err))
|
||||||
try:
|
try:
|
||||||
self.clean_up(cmd, result, err)
|
self.clean_up(cmd, result, err)
|
||||||
except Exception as err2:
|
except Exception as err2:
|
||||||
if self.options.debug:
|
if self.options.debug:
|
||||||
self.log.exception(six.text_type(err2))
|
self.log.exception(str(err2))
|
||||||
else:
|
else:
|
||||||
self.log.error('Could not clean up: %s',
|
self.log.error('Could not clean up: %s',
|
||||||
six.text_type(err2))
|
str(err2))
|
||||||
if self.options.debug:
|
if self.options.debug:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
@@ -309,10 +308,10 @@ class BlazarShell(app.App):
|
|||||||
self.clean_up(cmd, result, None)
|
self.clean_up(cmd, result, None)
|
||||||
except Exception as err3:
|
except Exception as err3:
|
||||||
if self.options.debug:
|
if self.options.debug:
|
||||||
self.log.exception(six.text_type(err3))
|
self.log.exception(str(err3))
|
||||||
else:
|
else:
|
||||||
self.log.error('Could not clean up: %s',
|
self.log.error('Could not clean up: %s',
|
||||||
six.text_type(err3))
|
str(err3))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def authenticate_user(self):
|
def authenticate_user(self):
|
||||||
@@ -349,7 +348,7 @@ class BlazarShell(app.App):
|
|||||||
def clean_up(self, cmd, result, err):
|
def clean_up(self, cmd, result, err):
|
||||||
self.log.debug('clean_up %s', cmd.__class__.__name__)
|
self.log.debug('clean_up %s', cmd.__class__.__name__)
|
||||||
if err:
|
if err:
|
||||||
self.log.debug('got an error: %s', six.text_type(err))
|
self.log.debug('got an error: %s', str(err))
|
||||||
|
|
||||||
def configure_logging(self):
|
def configure_logging(self):
|
||||||
"""Create logging handlers for any log output."""
|
"""Create logging handlers for any log output."""
|
||||||
@@ -383,7 +382,7 @@ def main(argv=sys.argv[1:]):
|
|||||||
except exception.BlazarClientException:
|
except exception.BlazarClientException:
|
||||||
return 1
|
return 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(six.text_type(e))
|
print(str(e))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import io
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
@@ -53,8 +53,8 @@ class BlazarShellTestCase(tests.TestCase):
|
|||||||
orig = sys.stdout
|
orig = sys.stdout
|
||||||
orig_stderr = sys.stderr
|
orig_stderr = sys.stderr
|
||||||
try:
|
try:
|
||||||
sys.stdout = six.StringIO()
|
sys.stdout = io.StringIO()
|
||||||
sys.stderr = six.StringIO()
|
sys.stderr = io.StringIO()
|
||||||
_shell = shell.BlazarShell()
|
_shell = shell.BlazarShell()
|
||||||
_shell.initialize_app(argstr.split())
|
_shell.initialize_app(argstr.split())
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ PyYAML==3.12
|
|||||||
requests==2.14.2
|
requests==2.14.2
|
||||||
requestsexceptions==1.2.0
|
requestsexceptions==1.2.0
|
||||||
rfc3986==0.3.1
|
rfc3986==0.3.1
|
||||||
six==1.10.0
|
|
||||||
stevedore==1.20.0
|
stevedore==1.20.0
|
||||||
testrepository==0.0.18
|
testrepository==0.0.18
|
||||||
testtools==2.2.0
|
testtools==2.2.0
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||||
cliff!=2.9.0,>=2.8.0 # Apache-2.0
|
cliff!=2.9.0,>=2.8.0 # Apache-2.0
|
||||||
PrettyTable<0.8,>=0.7.1 # BSD
|
PrettyTable<0.8,>=0.7.1 # BSD
|
||||||
six>=1.10.0 # MIT
|
|
||||||
Babel!=2.4.0,>=2.3.4 # BSD
|
Babel!=2.4.0,>=2.3.4 # BSD
|
||||||
oslo.i18n>=3.15.3 # Apache-2.0
|
oslo.i18n>=3.15.3 # Apache-2.0
|
||||||
oslo.log>=3.36.0 # Apache-2.0
|
oslo.log>=3.36.0 # Apache-2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user