Use six.with_metaclass to specify metaclasses

Metaclass specification is incompatible between Python 2 and 3. Use the
six.with_metaclass helper to specify metaclasses.

Reviewed-By: Petr Viktorin <pviktori@redhat.com>
This commit is contained in:
Jan Cholasta
2015-08-26 13:29:18 +02:00
parent 198908ec78
commit ebdfa4380b
3 changed files with 7 additions and 11 deletions

View File

@@ -54,8 +54,7 @@ class KnobValueError(ValueError):
self.name = name
class InnerClass(object):
__metaclass__ = util.InnerClassMeta
class InnerClass(six.with_metaclass(util.InnerClassMeta, object)):
__outer_class__ = None
__outer_name__ = None
@@ -162,15 +161,13 @@ def Knob(type, default=_missing, initializable=_missing, sensitive=_missing,
return util.InnerClassMeta('Knob', (KnobBase,), class_dict)
class Configurable(object):
class Configurable(six.with_metaclass(abc.ABCMeta, object)):
"""
Base class of all configurables.
FIXME: details of validate/execute, properties and knobs
"""
__metaclass__ = abc.ABCMeta
@classmethod
def knobs(cls):
"""
@@ -382,9 +379,8 @@ class ComponentMeta(util.InnerClassMeta, abc.ABCMeta):
pass
class ComponentBase(InnerClass, Configurable):
__metaclass__ = ComponentMeta
class ComponentBase(
six.with_metaclass(ComponentMeta, InnerClass, Configurable)):
_order = None
@classmethod

View File

@@ -159,5 +159,6 @@ class InnerClassMeta(type):
self.__outer_class__ = cls
self.__outer_name__ = name
self.__name__ = '.'.join((cls.__name__, name))
self.__qualname__ = self.__name__
return cls, name

View File

@@ -31,6 +31,7 @@ import dateutil.parser
import dateutil.tz
import nss.nss as nss
import gssapi
import six
from six.moves import xrange
from ipapython import admintool
@@ -147,10 +148,8 @@ def convertEncrypted(value, decryptor=None, pconv=base64.b64decode, econv=lambda
return None
class XMLKeyDerivation(object):
class XMLKeyDerivation(six.with_metaclass(abc.ABCMeta, object)):
"Interface for XML Encryption 1.1 key derivation."
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __init__(self, enckey):
"Sets up key derivation parameters from the parent XML entity."