From f541a293376aeeb965f728c44c17cdd0816de1fc Mon Sep 17 00:00:00 2001 From: zhurong Date: Thu, 16 Apr 2020 20:05:34 -0700 Subject: [PATCH] Remove six usage muranoclient/osc Change-Id: Iea5eab31f38510f5e5fcfed34c46b854cbef3a8e --- muranoclient/osc/v1/environment.py | 4 +-- muranoclient/osc/v1/package.py | 5 ++-- .../tests/unit/osc/v1/test_package.py | 26 +++++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/muranoclient/osc/v1/environment.py b/muranoclient/osc/v1/environment.py index 5059599c..74094c70 100644 --- a/muranoclient/osc/v1/environment.py +++ b/muranoclient/osc/v1/environment.py @@ -13,8 +13,8 @@ """Application-catalog v1 stack action implementation""" import json -import six import sys +import urllib import jsonpatch from osc_lib.command import command @@ -428,7 +428,7 @@ class EnvironmentModelShow(command.ShowOne): client = self.app.client_manager.application_catalog session_id = parsed_args.session_id or None - path = six.moves.urllib.parse.quote(parsed_args.path) + path = urllib.parse.quote(parsed_args.path) env_model = client.environments.get_model(parsed_args.id, path, session_id) diff --git a/muranoclient/osc/v1/package.py b/muranoclient/osc/v1/package.py index 7e37c81c..718d8ca6 100644 --- a/muranoclient/osc/v1/package.py +++ b/muranoclient/osc/v1/package.py @@ -17,7 +17,6 @@ import functools import itertools import os import shutil -import six import sys import tempfile import zipfile @@ -350,7 +349,7 @@ def _handle_package_exists(mc, data, package, exists_action): if not res: while True: print("What do you want to do? (s)kip, (u)pdate, (a)bort") - res = six.moves.input() + res = input() if res in allowed_results: break if res == 's': @@ -480,7 +479,7 @@ class ImportPackage(command.Lister): if dep_exists_action == '': dep_exists_action = parsed_args.exists_action - for name, package in six.iteritems(total_reqs): + for name, package in iter(total_reqs.items()): image_specs = package.images() if image_specs: print("Inspecting required images") diff --git a/muranoclient/tests/unit/osc/v1/test_package.py b/muranoclient/tests/unit/osc/v1/test_package.py index 28b1ca1b..cf0dfe78 100644 --- a/muranoclient/tests/unit/osc/v1/test_package.py +++ b/muranoclient/tests/unit/osc/v1/test_package.py @@ -10,10 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. +import io import json import os import shutil -import six import sys import tempfile @@ -102,7 +102,7 @@ class TestCreatePackage(TestPackage): parsed_args = self.check_parser(self.cmd, arglist, []) orig = sys.stdout try: - sys.stdout = six.StringIO() + sys.stdout = io.StringIO() self.cmd.take_action(parsed_args) finally: stdout = sys.stdout.getvalue() @@ -123,7 +123,7 @@ class TestCreatePackage(TestPackage): parsed_args = self.check_parser(self.cmd, arglist, []) orig = sys.stdout try: - sys.stdout = six.StringIO() + sys.stdout = io.StringIO() self.cmd.take_action(parsed_args) finally: stdout = sys.stdout.getvalue() @@ -281,7 +281,7 @@ class TestPackageImport(TestPackage): return f.name - @mock.patch('six.moves.input') + @mock.patch('builtins.input') @mock.patch('muranoclient.common.utils.Package.from_file') def test_package_import_conflict_skip(self, from_file, raw_input_mock): @@ -296,7 +296,7 @@ class TestPackageImport(TestPackage): 'is_public': False, }, {name: mock.ANY},) - @mock.patch('six.moves.input') + @mock.patch('builtins.input') @mock.patch('muranoclient.common.utils.Package.from_file') def test_package_import_conflict_skip_ea(self, from_file, raw_input_mock): @@ -313,7 +313,7 @@ class TestPackageImport(TestPackage): }, {name: mock.ANY},) self.assertFalse(raw_input_mock.called) - @mock.patch('six.moves.input') + @mock.patch('builtins.input') @mock.patch('muranoclient.common.utils.Package.from_file') def test_package_import_conflict_abort(self, from_file, raw_input_mock): @@ -328,7 +328,7 @@ class TestPackageImport(TestPackage): 'is_public': False, }, mock.ANY,) - @mock.patch('six.moves.input') + @mock.patch('builtins.input') @mock.patch('muranoclient.common.utils.Package.from_file') def test_package_import_conflict_abort_ea(self, from_file, raw_input_mock): @@ -346,7 +346,7 @@ class TestPackageImport(TestPackage): }, mock.ANY,) self.assertFalse(raw_input_mock.called) - @mock.patch('six.moves.input') + @mock.patch('builtins.input') @mock.patch('muranoclient.common.utils.Package.from_file') def test_package_import_conflict_update(self, from_file, raw_input_mock): @@ -367,7 +367,7 @@ class TestPackageImport(TestPackage): ], any_order=True, ) - @mock.patch('six.moves.input') + @mock.patch('builtins.input') @mock.patch('muranoclient.common.utils.Package.from_file') def test_package_import_conflict_update_ea(self, from_file, raw_input_mock): @@ -570,13 +570,13 @@ class TestBundleImport(TestPackage): m.get(murano_repo_url + '/apps/first_app.zip', body=pkg1) m.get(murano_repo_url + '/apps/second_app.1.0.zip', body=pkg2) - s = six.StringIO() + s = io.StringIO() bundle_contents = {'Packages': [ {'Name': 'first_app'}, {'Name': 'second_app', 'Version': '1.0'} ]} json.dump(bundle_contents, s) - s = six.BytesIO(s.getvalue().encode('ascii')) + s = io.BytesIO(s.getvalue().encode('ascii')) m.get(murano_repo_url + '/bundles/test_bundle.bundle', body=s) @@ -624,13 +624,13 @@ class TestBundleImport(TestPackage): m.get(murano_repo_url + '/apps/first_app.zip', body=pkg1) m.get(murano_repo_url + '/apps/second_app.1.0.zip', body=pkg2) - s = six.StringIO() + s = io.StringIO() bundle_contents = {'Packages': [ {'Name': 'first_app'}, {'Name': 'second_app', 'Version': '1.0'} ]} json.dump(bundle_contents, s) - s = six.BytesIO(s.getvalue().encode('ascii')) + s = io.BytesIO(s.getvalue().encode('ascii')) url = 'http://127.0.0.2/test_bundle.bundle' m.get(url, body=s)