Remove six murano/packages

Depends-On: https://review.opendev.org/#/c/720860/
Change-Id: I88d5b21c24780223196ff3bb7c629f404c343f14
This commit is contained in:
zhurong 2020-04-17 20:28:02 -07:00
parent f3f2a4019a
commit 07242fc255
6 changed files with 14 additions and 32 deletions

View File

@ -13,15 +13,11 @@
# 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 six
import murano.common.exceptions as e import murano.common.exceptions as e
class PackageException(e.Error): class PackageException(e.Error):
if six.PY2: pass
def __str__(self):
return six.text_type(self.message).encode('UTF-8')
class PackageClassLoadError(PackageException): class PackageClassLoadError(PackageException):

View File

@ -16,7 +16,6 @@ import os
import shutil import shutil
import sys import sys
import six
import yaml import yaml
from murano.common.helpers import path from murano.common.helpers import path
@ -253,7 +252,7 @@ class HotPackage(package_base.PackageBase):
@staticmethod @staticmethod
def _format_value(value): def _format_value(value):
if isinstance(value, six.string_types): if isinstance(value, str):
return str("'" + value + "'") return str("'" + value + "'")
return str(value) return str(value)

View File

@ -19,11 +19,11 @@ import sys
import tempfile import tempfile
import zipfile import zipfile
import six
import yaml import yaml
from murano.common.helpers import path from murano.common.helpers import path
from murano.common.plugins import package_types_loader from murano.common.plugins import package_types_loader
from murano.common import utils
import murano.packages.exceptions as e import murano.packages.exceptions as e
import murano.packages.hot_package import murano.packages.hot_package
import murano.packages.mpl_package import murano.packages.mpl_package
@ -93,7 +93,7 @@ def load_from_dir(source_directory, filename='manifest.yaml'):
content = yaml.safe_load(stream) content = yaml.safe_load(stream)
except Exception as ex: except Exception as ex:
trace = sys.exc_info()[2] trace = sys.exc_info()[2]
six.reraise( utils.reraise(
e.PackageLoadError, e.PackageLoadError,
e.PackageLoadError("Unable to load due to '{0}'".format(ex)), e.PackageLoadError("Unable to load due to '{0}'".format(ex)),
trace) trace)

View File

@ -18,8 +18,6 @@ import io
import os import os
import zipfile import zipfile
import six
from murano.common.helpers import path from murano.common.helpers import path
@ -29,8 +27,7 @@ class PackageType(object):
ALL = [Library, Application] ALL = [Library, Application]
@six.add_metaclass(abc.ABCMeta) class Package(object, metaclass=abc.ABCMeta):
class Package(object):
def __init__(self, format_name, runtime_version, source_directory): def __init__(self, format_name, runtime_version, source_directory):
self._source_directory = source_directory self._source_directory = source_directory
self._format_name = format_name self._format_name = format_name

View File

@ -20,10 +20,10 @@ import re
import sys import sys
import semantic_version import semantic_version
import six
from murano.common.helpers import path from murano.common.helpers import path
from murano.common.i18n import _ from murano.common.i18n import _
from murano.common import utils
from murano.packages import exceptions from murano.packages import exceptions
from murano.packages import package from murano.packages import package
@ -153,10 +153,11 @@ class PackageBase(package.Package):
except Exception as ex: except Exception as ex:
trace = sys.exc_info()[2] trace = sys.exc_info()[2]
six.reraise(exceptions.PackageLoadError, utils.reraise(
exceptions.PackageLoadError( exceptions.PackageLoadError,
'Unable to load {0}: {1}'.format(what_image, ex)), exceptions.PackageLoadError(
trace) 'Unable to load {0}: {1}'.format(what_image, ex)),
trace)
@staticmethod @staticmethod
def _check_full_name(full_name): def _check_full_name(full_name):

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six
from murano.packages import exceptions from murano.packages import exceptions
import murano.tests.unit.base as test_base import murano.tests.unit.base as test_base
@ -28,10 +26,7 @@ class TestExceptions(test_base.MuranoTestCase):
message=message) message=message)
expected = 'Unable to load class "{0}" from package: {1}'\ expected = 'Unable to load class "{0}" from package: {1}'\
.format(class_name, message) .format(class_name, message)
if six.PY2: self.assertEqual(expected, error.args[0])
self.assertEqual(expected, error.message)
elif six.PY34:
self.assertEqual(expected, error.args[0])
def test_package_ui_load_error(self): def test_package_ui_load_error(self):
messages = ['', 'test_message'] messages = ['', 'test_message']
@ -40,10 +35,7 @@ class TestExceptions(test_base.MuranoTestCase):
expected = 'Unable to load ui definition from package' expected = 'Unable to load ui definition from package'
if message: if message:
expected += ': {0}'.format(message) expected += ': {0}'.format(message)
if six.PY2: self.assertEqual(expected, error.args[0])
self.assertEqual(expected, error.message)
elif six.PY34:
self.assertEqual(expected, error.args[0])
def test_package_format_error(self): def test_package_format_error(self):
messages = ['', 'test_message'] messages = ['', 'test_message']
@ -52,7 +44,4 @@ class TestExceptions(test_base.MuranoTestCase):
expected = 'Incorrect package format' expected = 'Incorrect package format'
if message: if message:
expected += ': {0}'.format(message) expected += ': {0}'.format(message)
if six.PY2: self.assertEqual(expected, error.args[0])
self.assertEqual(expected, error.message)
elif six.PY34:
self.assertEqual(expected, error.args[0])