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