Remove six usage
Change-Id: If2317db47c323b537bc5c4bb8a0f11173418cd67
This commit is contained in:
parent
424fce53a5
commit
a83a360d46
|
@ -35,7 +35,6 @@ reno==2.5.0
|
||||||
requests==2.14.2
|
requests==2.14.2
|
||||||
requestsexceptions==1.2.0
|
requestsexceptions==1.2.0
|
||||||
semantic-version==2.3.1
|
semantic-version==2.3.1
|
||||||
six==1.10.0
|
|
||||||
snowballstemmer==1.2.1
|
snowballstemmer==1.2.1
|
||||||
Sphinx==1.6.2
|
Sphinx==1.6.2
|
||||||
sphinxcontrib-websupport==1.0.1
|
sphinxcontrib-websupport==1.0.1
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
|
|
||||||
from muranopkgcheck.checkers import yaql_checker
|
from muranopkgcheck.checkers import yaql_checker
|
||||||
from muranopkgcheck import error
|
from muranopkgcheck import error
|
||||||
|
@ -118,7 +117,7 @@ class CheckCodeStructure(object):
|
||||||
self._yaql_checker = yaql_checker.YaqlChecker()
|
self._yaql_checker = yaql_checker.YaqlChecker()
|
||||||
|
|
||||||
def string(self, value):
|
def string(self, value):
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, str):
|
||||||
yield error.report.E203('Value of "{0}" should be a string'
|
yield error.report.E203('Value of "{0}" should be a string'
|
||||||
''.format(value), value)
|
''.format(value), value)
|
||||||
|
|
||||||
|
@ -159,7 +158,7 @@ class CheckCodeStructure(object):
|
||||||
|
|
||||||
def _check_assigment(self, block):
|
def _check_assigment(self, block):
|
||||||
key = next(iter(block))
|
key = next(iter(block))
|
||||||
if not isinstance(key, six.string_types) or\
|
if not isinstance(key, str) or\
|
||||||
not ASSIGMENT_KEY.match(key):
|
not ASSIGMENT_KEY.match(key):
|
||||||
yield error.report.E201('"{0}" is not valid variable name'
|
yield error.report.E201('"{0}" is not valid variable name'
|
||||||
''.format(key), key)
|
''.format(key), key)
|
||||||
|
@ -167,7 +166,7 @@ class CheckCodeStructure(object):
|
||||||
def _single_block(self, block):
|
def _single_block(self, block):
|
||||||
if isinstance(block, dict):
|
if isinstance(block, dict):
|
||||||
yield self._check_structure(block)
|
yield self._check_structure(block)
|
||||||
elif isinstance(block, six.string_types):
|
elif isinstance(block, str):
|
||||||
yield self.yaql(block)
|
yield self.yaql(block)
|
||||||
|
|
||||||
def _run_check(self, check, value):
|
def _run_check(self, check, value):
|
||||||
|
|
|
@ -16,8 +16,6 @@ import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
import muranopkgcheck
|
import muranopkgcheck
|
||||||
from muranopkgcheck import log
|
from muranopkgcheck import log
|
||||||
from muranopkgcheck import manager
|
from muranopkgcheck import manager
|
||||||
|
@ -130,11 +128,11 @@ def main():
|
||||||
else:
|
else:
|
||||||
errors = run(args)
|
errors = run(args)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
LOG.error(six.text_type(e))
|
LOG.error(str(e))
|
||||||
print(six.text_type(e))
|
print(str(e))
|
||||||
return 2
|
return 2
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.critical(six.text_type(e), exc_info=sys.exc_info())
|
LOG.critical(str(e), exc_info=sys.exc_info())
|
||||||
return 3
|
return 3
|
||||||
if errors:
|
if errors:
|
||||||
print(errors)
|
print(errors)
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
CRITICAL = logging.CRITICAL
|
CRITICAL = logging.CRITICAL
|
||||||
ERROR = logging.ERROR
|
ERROR = logging.ERROR
|
||||||
WARNING = logging.WARNING
|
WARNING = logging.WARNING
|
||||||
|
@ -38,7 +36,7 @@ def setup(external_logging=None, log_format=LOG_FORMAT, level=DEFAULT_LEVEL):
|
||||||
console_log_handler = logging.StreamHandler()
|
console_log_handler = logging.StreamHandler()
|
||||||
console_log_handler.setFormatter(logging.Formatter(log_format))
|
console_log_handler.setFormatter(logging.Formatter(log_format))
|
||||||
global _loggers
|
global _loggers
|
||||||
for logger in six.itervalues(_loggers):
|
for logger in _loggers.values():
|
||||||
logger.setLevel(level)
|
logger.setLevel(level)
|
||||||
for h in logger.handlers:
|
for h in logger.handlers:
|
||||||
logger.removeHandler(h)
|
logger.removeHandler(h)
|
||||||
|
|
|
@ -18,7 +18,6 @@ import pprint
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
|
||||||
import six
|
|
||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
from muranopkgcheck import error
|
from muranopkgcheck import error
|
||||||
|
@ -32,8 +31,7 @@ LOG = log.getLogger(__name__)
|
||||||
error.register.E000(description='Check failed')
|
error.register.E000(description='Check failed')
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class Formatter(object, metaclass=abc.ABCMeta):
|
||||||
class Formatter(object):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def format(self, error):
|
def format(self, error):
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
|
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
from io import BytesIO
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from muranopkgcheck import consts
|
from muranopkgcheck import consts
|
||||||
|
@ -45,15 +45,14 @@ class FileWrapper(object):
|
||||||
|
|
||||||
def yaml(self):
|
def yaml(self):
|
||||||
if self._yaml is None:
|
if self._yaml is None:
|
||||||
sio = six.BytesIO(self.raw())
|
sio = BytesIO(self.raw())
|
||||||
setattr(sio, 'name', self._name)
|
setattr(sio, 'name', self._name)
|
||||||
self._yaml = list(yaml.load_all(sio,
|
self._yaml = list(yaml.load_all(sio,
|
||||||
yaml_loader.YamlLoader))
|
yaml_loader.YamlLoader))
|
||||||
return self._yaml
|
return self._yaml
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseLoader(object, metaclass=abc.ABCMeta):
|
||||||
class BaseLoader(object):
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
self._cached_files = dict()
|
self._cached_files = dict()
|
||||||
|
@ -106,12 +105,12 @@ class BaseLoader(object):
|
||||||
|
|
||||||
def try_set_format(self, manifest):
|
def try_set_format(self, manifest):
|
||||||
if manifest and 'Format' in manifest:
|
if manifest and 'Format' in manifest:
|
||||||
if '/' in six.text_type(manifest['Format']):
|
if '/' in str(manifest['Format']):
|
||||||
fmt, version = manifest['Format'].split('/', 1)
|
fmt, version = manifest['Format'].split('/', 1)
|
||||||
self.format = fmt
|
self.format = fmt
|
||||||
self.format_version = version
|
self.format_version = version
|
||||||
else:
|
else:
|
||||||
self.format_version = six.text_type(manifest['Format'])
|
self.format_version = str(manifest['Format'])
|
||||||
|
|
||||||
|
|
||||||
class DirectoryLoader(BaseLoader):
|
class DirectoryLoader(BaseLoader):
|
||||||
|
@ -150,7 +149,7 @@ class ZipLoader(BaseLoader):
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
super(ZipLoader, self).__init__(path)
|
super(ZipLoader, self).__init__(path)
|
||||||
if hasattr(self.path, 'read'):
|
if hasattr(self.path, 'read'):
|
||||||
self._zipfile = zipfile.ZipFile(six.BytesIO(self.path.read()))
|
self._zipfile = zipfile.ZipFile(BytesIO(self.path.read()))
|
||||||
else:
|
else:
|
||||||
self._zipfile = zipfile.ZipFile(self.path)
|
self._zipfile = zipfile.ZipFile(self.path)
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,8 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
|
class Plugin(object, metaclass=abc.ABCMeta):
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
|
||||||
class Plugin(object):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def validators(self):
|
def validators(self):
|
||||||
|
|
|
@ -16,7 +16,6 @@ import io
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import oslotest.base
|
import oslotest.base
|
||||||
import six
|
|
||||||
import testscenarios
|
import testscenarios
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
@ -39,11 +38,11 @@ class DictLoader(pkg_loader.BaseLoader):
|
||||||
|
|
||||||
def open_file(self, path, mode='r'):
|
def open_file(self, path, mode='r'):
|
||||||
if self.pkg[path]['format'] == 'raw':
|
if self.pkg[path]['format'] == 'raw':
|
||||||
sio = io.BytesIO(six.b(self.pkg[path]['content']))
|
sio = io.BytesIO(self.pkg[path]['content'].encode())
|
||||||
setattr(sio, 'name', path)
|
setattr(sio, 'name', path)
|
||||||
elif self.pkg[path]['format'] == 'yaml':
|
elif self.pkg[path]['format'] == 'yaml':
|
||||||
content = yaml.safe_dump(self.pkg[path]['content'])
|
content = yaml.safe_dump(self.pkg[path]['content'])
|
||||||
sio = io.BytesIO(six.b(content))
|
sio = io.BytesIO(content.encode())
|
||||||
setattr(sio, 'name', path)
|
setattr(sio, 'name', path)
|
||||||
else:
|
else:
|
||||||
raise ValueError('Unknown type of content')
|
raise ValueError('Unknown type of content')
|
||||||
|
|
|
@ -12,8 +12,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 muranopkgcheck.checkers import code_structure
|
from muranopkgcheck.checkers import code_structure
|
||||||
from muranopkgcheck.tests import test_validator_helpers as helpers
|
from muranopkgcheck.tests import test_validator_helpers as helpers
|
||||||
|
|
||||||
|
@ -97,7 +95,7 @@ class CodeStructureTest(helpers.BaseValidatorTestClass):
|
||||||
self.g = self._checker.codeblock(MULTILINE_BODY)
|
self.g = self._checker.codeblock(MULTILINE_BODY)
|
||||||
p1 = next(self.g)
|
p1 = next(self.g)
|
||||||
p2 = next(self.g)
|
p2 = next(self.g)
|
||||||
six.assertCountEqual(self, [
|
self.assertCountEqual([
|
||||||
'Unknown keyword "Does" in "While"',
|
'Unknown keyword "Does" in "While"',
|
||||||
'Missing keyword "Do" for "While" code structure'],
|
'Missing keyword "Do" for "While" code structure'],
|
||||||
[p1.message, p2.message])
|
[p1.message, p2.message])
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from io import BytesIO
|
||||||
import mock
|
import mock
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
import yaml.error
|
import yaml.error
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ class FileWrapperTest(base.TestCase):
|
||||||
m_yaml.load_all.side_effect = yaml.load_all
|
m_yaml.load_all.side_effect = yaml.load_all
|
||||||
fake_pkg = mock.Mock()
|
fake_pkg = mock.Mock()
|
||||||
fake_pkg.open_file.side_effect = \
|
fake_pkg.open_file.side_effect = \
|
||||||
lambda f: mock.mock_open(read_data=six.b('text'))()
|
lambda f: mock.mock_open(read_data=b'text')()
|
||||||
f = pkg_loader.FileWrapper(fake_pkg, 'fake_path')
|
f = pkg_loader.FileWrapper(fake_pkg, 'fake_path')
|
||||||
self.assertEqual(six.b('text'), f.raw())
|
self.assertEqual(b'text', f.raw())
|
||||||
|
|
||||||
self.assertEqual(['text'], f.yaml())
|
self.assertEqual(['text'], f.yaml())
|
||||||
m_yaml.load_all.assert_called()
|
m_yaml.load_all.assert_called()
|
||||||
|
@ -43,9 +43,9 @@ class FileWrapperTest(base.TestCase):
|
||||||
m_yaml.load_all.assert_not_called()
|
m_yaml.load_all.assert_not_called()
|
||||||
|
|
||||||
fake_pkg.open_file.side_effect = \
|
fake_pkg.open_file.side_effect = \
|
||||||
lambda f: mock.mock_open(read_data=six.b('!@#$%'))()
|
lambda f: mock.mock_open(read_data=b'!@#$%')()
|
||||||
f = pkg_loader.FileWrapper(fake_pkg, six.b('fake_path'))
|
f = pkg_loader.FileWrapper(fake_pkg, b'fake_path')
|
||||||
self.assertEqual(six.b('!@#$%'), f.raw())
|
self.assertEqual(b'!@#$%', f.raw())
|
||||||
self.assertRaises(yaml.error.YAMLError, f.yaml)
|
self.assertRaises(yaml.error.YAMLError, f.yaml)
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,8 +219,8 @@ class ZipLoaderTest(base.TestCase):
|
||||||
m_read):
|
m_read):
|
||||||
m_read.return_value.yaml.return_value = [{'FullName': 'fake'}]
|
m_read.return_value.yaml.return_value = [{'FullName': 'fake'}]
|
||||||
m_exists.return_value = True
|
m_exists.return_value = True
|
||||||
m_content = six.b('fake')
|
m_content = b'fake'
|
||||||
loader = pkg_loader.ZipLoader.try_load(six.BytesIO(m_content))
|
loader = pkg_loader.ZipLoader.try_load(BytesIO(m_content))
|
||||||
self.assertIsNotNone(loader)
|
self.assertIsNotNone(loader)
|
||||||
m_try_set_format.assert_called_once_with({'FullName': 'fake'})
|
m_try_set_format.assert_called_once_with({'FullName': 'fake'})
|
||||||
m_zip.ZipFile.assert_called()
|
m_zip.ZipFile.assert_called()
|
||||||
|
|
|
@ -16,8 +16,6 @@ import abc
|
||||||
import itertools
|
import itertools
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from muranopkgcheck import error
|
from muranopkgcheck import error
|
||||||
from muranopkgcheck.i18n import _
|
from muranopkgcheck.i18n import _
|
||||||
|
|
||||||
|
@ -32,8 +30,7 @@ error.register.E040(description='Value should be string')
|
||||||
error.register.W010(description='Unknown keyword')
|
error.register.W010(description='Unknown keyword')
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseValidator(object, metaclass=abc.ABCMeta):
|
||||||
class BaseValidator(object):
|
|
||||||
|
|
||||||
def __init__(self, loaded_package, _filter='.*'):
|
def __init__(self, loaded_package, _filter='.*'):
|
||||||
self._loaded_pkg = loaded_package
|
self._loaded_pkg = loaded_package
|
||||||
|
@ -44,22 +41,22 @@ class BaseValidator(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _valid_string(self, value):
|
def _valid_string(self, value):
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, str):
|
||||||
yield error.report.E040(_('Value is not a string "{}"'
|
yield error.report.E040(_('Value is not a string "{}"'
|
||||||
'').format(value), value)
|
'').format(value), value)
|
||||||
|
|
||||||
def _check_name(self, name):
|
def _check_name(self, name):
|
||||||
if isinstance(name, six.string_types) and NAME_REGEX.match(name):
|
if isinstance(name, str) and NAME_REGEX.match(name):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _check_fqn_name(self, fqn):
|
def _check_fqn_name(self, fqn):
|
||||||
if isinstance(fqn, six.string_types) and FQN_REGEX.match(fqn):
|
if isinstance(fqn, str) and FQN_REGEX.match(fqn):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _check_ns_fqn_name(self, ns_fqn):
|
def _check_ns_fqn_name(self, ns_fqn):
|
||||||
if isinstance(ns_fqn, six.string_types):
|
if isinstance(ns_fqn, str):
|
||||||
if ':' in ns_fqn:
|
if ':' in ns_fqn:
|
||||||
ns, fqn = ns_fqn.split(':', 1)
|
ns, fqn = ns_fqn.split(':', 1)
|
||||||
if NAME_REGEX.match(ns) and FQN_REGEX.match(fqn):
|
if NAME_REGEX.match(ns) and FQN_REGEX.match(fqn):
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
import semantic_version
|
import semantic_version
|
||||||
import six
|
|
||||||
|
|
||||||
from muranopkgcheck import consts
|
from muranopkgcheck import consts
|
||||||
from muranopkgcheck import error
|
from muranopkgcheck import error
|
||||||
|
@ -58,7 +57,7 @@ class ManifestValidator(base.YamlValidator):
|
||||||
self.add_checker(self._valid_logo_ui_existance)
|
self.add_checker(self._valid_logo_ui_existance)
|
||||||
|
|
||||||
def _valid_description(self, desc):
|
def _valid_description(self, desc):
|
||||||
if not isinstance(desc, six.string_types) and\
|
if not isinstance(desc, str) and\
|
||||||
not isinstance(desc, yaml_loader.YamlNull):
|
not isinstance(desc, yaml_loader.YamlNull):
|
||||||
yield error.report.E030('Value is not valid string "{0}"'
|
yield error.report.E030('Value is not valid string "{0}"'
|
||||||
.format(desc), desc)
|
.format(desc), desc)
|
||||||
|
@ -113,7 +112,7 @@ class ManifestValidator(base.YamlValidator):
|
||||||
yield self._valid_ui('ui.yaml')
|
yield self._valid_ui('ui.yaml')
|
||||||
|
|
||||||
def _valid_ui(self, value):
|
def _valid_ui(self, value):
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, str):
|
||||||
pkg_type = self._loaded_pkg.read(
|
pkg_type = self._loaded_pkg.read(
|
||||||
consts.MANIFEST_PATH).yaml()[0]['Type']
|
consts.MANIFEST_PATH).yaml()[0]['Type']
|
||||||
if pkg_type == 'Library':
|
if pkg_type == 'Library':
|
||||||
|
@ -125,7 +124,7 @@ class ManifestValidator(base.YamlValidator):
|
||||||
yield error.report.E072(_('UI is not a string'), value)
|
yield error.report.E072(_('UI is not a string'), value)
|
||||||
|
|
||||||
def _valid_logo(self, value):
|
def _valid_logo(self, value):
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, str):
|
||||||
pkg_type = self._loaded_pkg.read(
|
pkg_type = self._loaded_pkg.read(
|
||||||
consts.MANIFEST_PATH).yaml()[0]['Type']
|
consts.MANIFEST_PATH).yaml()[0]['Type']
|
||||||
if pkg_type == 'Library':
|
if pkg_type == 'Library':
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from muranopkgcheck.checkers import code_structure
|
from muranopkgcheck.checkers import code_structure
|
||||||
from muranopkgcheck.checkers import yaql_checker
|
from muranopkgcheck.checkers import yaql_checker
|
||||||
from muranopkgcheck import error
|
from muranopkgcheck import error
|
||||||
|
@ -95,7 +93,7 @@ class MuranoPLValidator(base.YamlValidator):
|
||||||
for apl in applies:
|
for apl in applies:
|
||||||
yield self._valid_applies(apl, False)
|
yield self._valid_applies(apl, False)
|
||||||
else:
|
else:
|
||||||
if not isinstance(applies, six.string_types) or \
|
if not isinstance(applies, str) or \
|
||||||
applies not in APPLIES_VALUES:
|
applies not in APPLIES_VALUES:
|
||||||
yield error.report.E028(
|
yield error.report.E028(
|
||||||
_('Wrong Applies "{0}"').format(applies), applies)
|
_('Wrong Applies "{0}"').format(applies), applies)
|
||||||
|
@ -109,7 +107,7 @@ class MuranoPLValidator(base.YamlValidator):
|
||||||
'class "{0}"').format(import_), import_)
|
'class "{0}"').format(import_), import_)
|
||||||
|
|
||||||
def _valid_name(self, value):
|
def _valid_name(self, value):
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, str):
|
||||||
yield error.report.E011(_('Invalid class name "{}". '
|
yield error.report.E011(_('Invalid class name "{}". '
|
||||||
'Class name should be a string')
|
'Class name should be a string')
|
||||||
.format(value), value)
|
.format(value), value)
|
||||||
|
@ -129,7 +127,7 @@ class MuranoPLValidator(base.YamlValidator):
|
||||||
if can_be_list and isinstance(value, list):
|
if can_be_list and isinstance(value, list):
|
||||||
for cls in value:
|
for cls in value:
|
||||||
yield self._valid_extends(cls, False)
|
yield self._valid_extends(cls, False)
|
||||||
elif isinstance(value, six.string_types):
|
elif isinstance(value, str):
|
||||||
if not self._check_ns_fqn_name(value):
|
if not self._check_ns_fqn_name(value):
|
||||||
yield error.report.E025(_('Wrong FNQ of extended class "{}"'
|
yield error.report.E025(_('Wrong FNQ of extended class "{}"'
|
||||||
'').format(value), value)
|
'').format(value), value)
|
||||||
|
@ -156,7 +154,7 @@ class MuranoPLValidator(base.YamlValidator):
|
||||||
for c_key, c_value in contract.items():
|
for c_key, c_value in contract.items():
|
||||||
yield self._valid_string(c_key)
|
yield self._valid_string(c_key)
|
||||||
yield self._valid_contract(c_value)
|
yield self._valid_contract(c_value)
|
||||||
elif isinstance(contract, six.string_types):
|
elif isinstance(contract, str):
|
||||||
if not self.yaql_checker(contract) or \
|
if not self.yaql_checker(contract) or \
|
||||||
not contract.startswith('$.') and contract != '$':
|
not contract.startswith('$.') and contract != '$':
|
||||||
yield error.report.W048(_('Contract is not valid yaql "{}"'
|
yield error.report.W048(_('Contract is not valid yaql "{}"'
|
||||||
|
@ -230,7 +228,7 @@ class MuranoPLValidator(base.YamlValidator):
|
||||||
yield self._valid_keywords(method_data.keys(), METHOD_KEYWORDS)
|
yield self._valid_keywords(method_data.keys(), METHOD_KEYWORDS)
|
||||||
|
|
||||||
def _valid_body(self, body):
|
def _valid_body(self, body):
|
||||||
if not isinstance(body, (list, six.string_types, dict)):
|
if not isinstance(body, (list, str, dict)):
|
||||||
yield error.report.E045(_('Body is not a list or scalar/yaql '
|
yield error.report.E045(_('Body is not a list or scalar/yaql '
|
||||||
'expression'), body)
|
'expression'), body)
|
||||||
else:
|
else:
|
||||||
|
@ -275,11 +273,11 @@ class MuranoPLValidator(base.YamlValidator):
|
||||||
yield error.report.E046(_('Methods single argument should be '
|
yield error.report.E046(_('Methods single argument should be '
|
||||||
'a one key dict'), argument)
|
'a one key dict'), argument)
|
||||||
else:
|
else:
|
||||||
name = next(six.iterkeys(argument))
|
name = next(iter(argument.keys()))
|
||||||
if not self._check_name(name):
|
if not self._check_name(name):
|
||||||
yield error.report.E054(_('Invalid name of argument "{}"')
|
yield error.report.E054(_('Invalid name of argument "{}"')
|
||||||
.format(name), name)
|
.format(name), name)
|
||||||
val = next(six.itervalues(argument))
|
val = next(iter(argument.values()))
|
||||||
contract = val.get('Contract')
|
contract = val.get('Contract')
|
||||||
if contract:
|
if contract:
|
||||||
yield self._valid_contract(contract)
|
yield self._valid_contract(contract)
|
||||||
|
|
|
@ -12,8 +12,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 muranopkgcheck import error
|
from muranopkgcheck import error
|
||||||
from muranopkgcheck.i18n import _
|
from muranopkgcheck.i18n import _
|
||||||
from muranopkgcheck.validators import base
|
from muranopkgcheck.validators import base
|
||||||
|
@ -71,7 +69,7 @@ class UiValidator(base.YamlValidator):
|
||||||
for named_params in form:
|
for named_params in form:
|
||||||
for key, value in named_params.items():
|
for key, value in named_params.items():
|
||||||
if key in STR_FIELDS:
|
if key in STR_FIELDS:
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, str):
|
||||||
yield error.report.E040(_('Value of {} should be '
|
yield error.report.E040(_('Value of {} should be '
|
||||||
'string not "{}"')
|
'string not "{}"')
|
||||||
.format(key, value), key)
|
.format(key, value), key)
|
||||||
|
|
|
@ -12,7 +12,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
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
__all__ = ['YamlLoader']
|
__all__ = ['YamlLoader']
|
||||||
|
@ -47,7 +46,7 @@ class YamlSequence(YamlObject, list):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class YamlString(YamlObject, six.text_type):
|
class YamlString(YamlObject, str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||||
PyYAML>=3.12 # MIT
|
PyYAML>=3.12 # MIT
|
||||||
yaql>=1.1.3 # Apache 2.0 License
|
yaql>=1.1.3 # Apache 2.0 License
|
||||||
six>=1.10.0 # MIT
|
|
||||||
stevedore>=1.20.0 # Apache-2.0
|
stevedore>=1.20.0 # Apache-2.0
|
||||||
semantic-version>=2.3.1 # BSD
|
semantic-version>=2.3.1 # BSD
|
||||||
oslo.i18n>=3.15.3 # Apache-2.0
|
oslo.i18n>=3.15.3 # Apache-2.0
|
||||||
|
|
Loading…
Reference in New Issue