Merge "Remove py2.7 support"
This commit is contained in:
commit
709967110d
|
@ -19,8 +19,6 @@ import itertools
|
|||
import re
|
||||
import weakref
|
||||
|
||||
import six
|
||||
|
||||
import charms.reactive as reactive
|
||||
import charms.reactive.bus
|
||||
import charmhelpers.contrib.hahelpers.cluster as ch_cluster
|
||||
|
@ -437,7 +435,7 @@ def make_default_configuration_adapter_class(base_cls=None,
|
|||
if not custom_properties:
|
||||
return base_cls
|
||||
# turns the functions into properties on the class
|
||||
properties = {n: property(f) for n, f in six.iteritems(custom_properties)}
|
||||
properties = {n: property(f) for n, f in custom_properties.items()}
|
||||
# build a custom class with the custom properties
|
||||
return type('DefaultConfigurationAdapter', (base_cls, ), properties)
|
||||
|
||||
|
@ -466,8 +464,7 @@ class ConfigurationAdapter(object):
|
|||
if charm_instance is not None:
|
||||
self._charm_instance_weakref = weakref.ref(charm_instance)
|
||||
# copy over (statically) the items of the charms Juju configuration
|
||||
_config = hookenv.config()
|
||||
for k, v in six.iteritems(_config):
|
||||
for k, v in hookenv.config().items():
|
||||
k = k.replace('-', '_')
|
||||
setattr(self, k, v)
|
||||
|
||||
|
@ -850,7 +847,7 @@ def make_default_relation_adapter(base_cls, relation, properties):
|
|||
if not properties:
|
||||
return base_cls
|
||||
# convert the functions into properties
|
||||
props = {n: property(f) for n, f in six.iteritems(properties)}
|
||||
props = {n: property(f) for n, f in properties.items()}
|
||||
# turn 'my-Something_interface' into 'MySomethingInterface'
|
||||
# future proof incase other chars come in which can't be in an Python Class
|
||||
# name.
|
||||
|
@ -923,10 +920,9 @@ class OpenStackRelationAdapters(object):
|
|||
for cls in reversed(self.__class__.mro()):
|
||||
self._adapters.update(
|
||||
{k.replace('-', '_'): v
|
||||
for k, v in six.iteritems(
|
||||
getattr(cls, 'relation_adapters', {}))})
|
||||
for k, v in getattr(cls, 'relation_adapters', {}).items()})
|
||||
# now we have to add in any customisations to those adapters
|
||||
for relation, properties in six.iteritems(_custom_adapter_properties):
|
||||
for relation, properties in _custom_adapter_properties.items():
|
||||
relation = relation.replace('-', '_')
|
||||
try:
|
||||
cls = self._adapters[relation]
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
# OpenStackCharm() - base class for build OpenStack charms from for the
|
||||
# reactive framework.
|
||||
|
||||
# need/want absolute imports for the package imports to work properly
|
||||
from __future__ import absolute_import
|
||||
|
||||
import base64
|
||||
import collections
|
||||
import contextlib
|
||||
|
@ -30,7 +27,6 @@ import string
|
|||
import subprocess
|
||||
|
||||
import apt_pkg as apt
|
||||
import six
|
||||
|
||||
import charmhelpers.contrib.network.ip as ch_ip
|
||||
import charmhelpers.contrib.openstack.templating as os_templating
|
||||
|
@ -478,8 +474,7 @@ class OpenStackCharmMeta(type):
|
|||
return _singleton
|
||||
|
||||
|
||||
@six.add_metaclass(OpenStackCharmMeta)
|
||||
class OpenStackCharm(object):
|
||||
class OpenStackCharm(object, metaclass=OpenStackCharmMeta):
|
||||
"""
|
||||
Base class for all OpenStack Charm classes;
|
||||
encapulates general OpenStack charm payload operations
|
||||
|
@ -1008,7 +1003,7 @@ class OpenStackCharm(object):
|
|||
available_states = reactive.bus.get_states().keys()
|
||||
status = None
|
||||
messages = []
|
||||
for relation, states in six.iteritems(states_to_check):
|
||||
for relation, states in states_to_check.items():
|
||||
for state, err_status, err_msg in states:
|
||||
if state not in available_states:
|
||||
messages.append(err_msg)
|
||||
|
@ -1159,7 +1154,7 @@ class OpenStackCharm(object):
|
|||
return None
|
||||
|
||||
vers_map = os_utils.OPENSTACK_CODENAMES
|
||||
for version, cname in six.iteritems(vers_map):
|
||||
for version, cname in vers_map.items():
|
||||
if cname == codename:
|
||||
return version
|
||||
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -26,7 +26,7 @@ basepython = python3.5
|
|||
deps = -r{toxinidir}/test-requirements.txt
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python2.7
|
||||
basepython = python3.5
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = flake8 {posargs} charms_openstack unit_tests
|
||||
|
||||
|
|
|
@ -18,14 +18,8 @@
|
|||
import contextlib
|
||||
import io
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
|
||||
if not six.PY3:
|
||||
builtin_open = '__builtin__.open'
|
||||
else:
|
||||
builtin_open = 'builtins.open'
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def patch_open():
|
||||
|
@ -41,7 +35,7 @@ def patch_open():
|
|||
mock_open(*args, **kwargs)
|
||||
yield mock_file
|
||||
|
||||
with mock.patch(builtin_open, stub_open):
|
||||
with mock.patch('builtins.open', stub_open):
|
||||
yield mock_open, mock_file
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue