Merge "Use six.add_metaclass instead of __metaclass__"

This commit is contained in:
Jenkins 2014-06-10 10:14:37 +00:00 committed by Gerrit Code Review
commit 2c4752b98b
5 changed files with 12 additions and 9 deletions

View File

@ -24,6 +24,7 @@ from django.utils.functional import Promise # noqa
from django.utils.http import urlencode # noqa
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
import six
from horizon import exceptions
from horizon import messages
@ -80,9 +81,9 @@ class BaseActionMetaClass(type):
return klass
@six.add_metaclass(BaseActionMetaClass)
class BaseAction(html.HTMLElement):
"""Common base class for all ``Action`` classes."""
__metaclass__ = BaseActionMetaClass
def __init__(self, **kwargs):
super(BaseAction, self).__init__()

View File

@ -33,6 +33,7 @@ from django.utils.http import urlencode
from django.utils.safestring import mark_safe
from django.utils import termcolors
from django.utils.translation import ugettext_lazy as _
import six
from horizon import conf
from horizon import exceptions
@ -1015,6 +1016,7 @@ class DataTableMetaclass(type):
return type.__new__(mcs, name, bases, attrs)
@six.add_metaclass(DataTableMetaclass)
class DataTable(object):
"""A class which defines a table with all data and associated actions.
@ -1039,7 +1041,6 @@ class DataTable(object):
:class:`~horizon.tables.FilterAction` class (if one is provided)
using the current request's query parameters.
"""
__metaclass__ = DataTableMetaclass
def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
self.request = request

View File

@ -26,6 +26,7 @@ from django.template.defaultfilters import slugify # noqa
from django.utils.encoding import force_unicode
from django.utils.importlib import import_module # noqa
from django.utils.translation import ugettext_lazy as _
import six
from horizon import base
from horizon import exceptions
@ -73,6 +74,7 @@ class ActionMetaclass(forms.forms.DeclarativeFieldsMetaclass):
return cls
@six.add_metaclass(ActionMetaclass)
class Action(forms.Form):
"""An ``Action`` represents an atomic logical interaction you can have with
the system. This is easier to understand with a conceptual example: in the
@ -123,8 +125,6 @@ class Action(forms.Form):
customize your help text template to display practically anything.
"""
__metaclass__ = ActionMetaclass
def __init__(self, request, context, *args, **kwargs):
if request.method == "POST":
super(Action, self).__init__(request.POST, initial=context)
@ -484,6 +484,7 @@ class UpdateMembersStep(Step):
return self.slug + "_role_" + role_id
@six.add_metaclass(WorkflowMetaclass)
class Workflow(html.HTMLElement):
"""A Workflow is a collection of Steps. Its interface is very
straightforward, but it is responsible for handling some very
@ -587,7 +588,6 @@ class Workflow(html.HTMLElement):
Defaults to ``False``.
"""
__metaclass__ = WorkflowMetaclass
slug = None
default_steps = ()
template_name = "horizon/common/_workflow.html"

View File

@ -21,7 +21,10 @@ methods defined in this module.
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class FloatingIpManager(object):
"""Abstract class to implement Floating IP methods
@ -37,8 +40,6 @@ class FloatingIpManager(object):
* instance_id: Instance ID of an associated with the Floating IP
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def list_pools(self):
"""Fetches a list of all floating IP pools.
@ -129,6 +130,7 @@ class FloatingIpManager(object):
pass
@six.add_metaclass(abc.ABCMeta)
class SecurityGroupManager(object):
"""Abstract class to implement Security Group methods
@ -159,8 +161,6 @@ class SecurityGroupManager(object):
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def list(self):
"""Fetches a list all security groups.

View File

@ -60,6 +60,7 @@ exclude = .venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,panel_
# H702 Formatting operation should be outside of localization method call
# H803 git commit title should not end with period (disabled on purpose, see bug #1236621)
ignore = E127,E128,H701,H702,H803
select = H236
[hacking]
import_exceptions = collections.defaultdict,