# HG changeset patch # User RĂ©mi Cardona # Date 1442404641 -7200 # Node ID fa29f3628a1bd7527430470fb0bb3c8315403a88 # Parent d394bfcd8c25ab918a15d5c089df6ff067bef017 [py3k] use six.add_metaclass diff -r d394bfcd8c25 -r fa29f3628a1b dataimport/deprecated.py --- a/dataimport/deprecated.py Wed Sep 16 11:28:07 2015 +0200 +++ b/dataimport/deprecated.py Wed Sep 16 13:57:21 2015 +0200 @@ -64,6 +64,8 @@ import traceback from StringIO import StringIO +from six import add_metaclass + from logilab.common import attrdict, shellutils from logilab.common.date import strptime from logilab.common.deprecation import deprecated, class_deprecated @@ -116,9 +118,9 @@ return answer == 'Y' +@add_metaclass(class_deprecated) class catch_error(object): """Helper for @contextmanager decorator.""" - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.21] deprecated' def __init__(self, ctl, key='unexpected error', msg=None): @@ -257,6 +259,7 @@ if k is not None and len(v) > 1] +@add_metaclass(class_deprecated) class ObjectStore(object): """Store objects in memory for *faster* validation (development mode) @@ -267,7 +270,6 @@ >>> group = store.prepare_insert_entity('CWUser', name=u'unknown') >>> store.prepare_insert_relation(user, 'in_group', group) """ - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.21] use the new importer API' def __init__(self): @@ -338,6 +340,7 @@ self.prepare_insert_relation(eid_from, rtype, eid_to, **kwargs) +@add_metaclass(class_deprecated) class CWImportController(object): """Controller of the data import process. @@ -346,7 +349,6 @@ >>> ctl.data = dict_of_data_tables >>> ctl.run() """ - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.21] use the new importer API' def __init__(self, store, askerror=0, catcherrors=None, tell=tell, diff -r d394bfcd8c25 -r fa29f3628a1b devtools/fill.py --- a/devtools/fill.py Wed Sep 16 11:28:07 2015 +0200 +++ b/devtools/fill.py Wed Sep 16 13:57:21 2015 +0200 @@ -27,6 +27,7 @@ from datetime import datetime, date, time, timedelta from decimal import Decimal +from six import add_metaclass from six.moves import range from logilab.common import attrdict @@ -262,8 +263,10 @@ setattr(_ValueGenerator, attrname, attrvalue) return type.__new__(mcs, name, bases, classdict) + +@add_metaclass(autoextend) class ValueGenerator(_ValueGenerator): - __metaclass__ = autoextend + pass def _default_choice_func(etype, attrname): diff -r d394bfcd8c25 -r fa29f3628a1b repoapi.py --- a/repoapi.py Wed Sep 16 11:28:07 2015 +0200 +++ b/repoapi.py Wed Sep 16 13:57:21 2015 +0200 @@ -18,6 +18,9 @@ """Official API to access the content of a repository """ from warnings import warn + +from six import add_metaclass + from logilab.common.deprecation import class_deprecated from cubicweb.utils import parse_repo_uri @@ -63,6 +66,6 @@ return connect(repo, anon_login, password=anon_password) +@add_metaclass(class_deprecated) class ClientConnection(Connection): - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.20] %(cls)s is deprecated, use Connection instead' diff -r d394bfcd8c25 -r fa29f3628a1b toolsutils.py --- a/toolsutils.py Wed Sep 16 11:28:07 2015 +0200 +++ b/toolsutils.py Wed Sep 16 13:57:21 2015 +0200 @@ -38,6 +38,8 @@ def symlink(*args): raise NotImplementedError +from six import add_metaclass + from logilab.common.clcommands import Command as BaseCommand from logilab.common.shellutils import ASK @@ -210,12 +212,13 @@ return cls +@add_metaclass(metacmdhandler) class CommandHandler(object): """configuration specific helper for cubicweb-ctl commands""" - __metaclass__ = metacmdhandler def __init__(self, config): self.config = config + class Command(BaseCommand): """base class for cubicweb-ctl commands""" diff -r d394bfcd8c25 -r fa29f3628a1b web/box.py --- a/web/box.py Wed Sep 16 11:28:07 2015 +0200 +++ b/web/box.py Wed Sep 16 13:57:21 2015 +0200 @@ -20,6 +20,8 @@ __docformat__ = "restructuredtext en" from cubicweb import _ +from six import add_metaclass + from logilab.mtconverter import xml_escape from logilab.common.deprecation import class_deprecated, class_renamed @@ -53,6 +55,7 @@ # old box system, deprecated ################################################### +@add_metaclass(class_deprecated) class BoxTemplate(View): """base template for boxes, usually a (contextual) list of possible actions. Various classes attributes may be used to control the box @@ -66,7 +69,6 @@ box.render(self.w) """ - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.10] *BoxTemplate classes are deprecated, use *CtxComponent instead (%(cls)s)' __registry__ = 'ctxcomponents' diff -r d394bfcd8c25 -r fa29f3628a1b web/component.py --- a/web/component.py Wed Sep 16 11:28:07 2015 +0200 +++ b/web/component.py Wed Sep 16 13:57:21 2015 +0200 @@ -24,6 +24,8 @@ from warnings import warn +from six import add_metaclass + from logilab.common.deprecation import class_deprecated, class_renamed, deprecated from logilab.mtconverter import xml_escape @@ -677,6 +679,7 @@ # old contextual components, deprecated ######################################## +@add_metaclass(class_deprecated) class EntityVComponent(Component): """abstract base class for additinal components displayed in content headers and footer according to: @@ -687,7 +690,6 @@ it should be configured using .accepts, .etype, .rtype, .target and .context class attributes """ - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.10] *VComponent classes are deprecated, use *CtxComponent instead (%(cls)s)' __registry__ = 'ctxcomponents' diff -r d394bfcd8c25 -r fa29f3628a1b web/form.py --- a/web/form.py Wed Sep 16 11:28:07 2015 +0200 +++ b/web/form.py Wed Sep 16 13:57:21 2015 +0200 @@ -20,6 +20,8 @@ from warnings import warn +from six import add_metaclass + from logilab.common.decorators import iclassmethod from logilab.common.deprecation import deprecated @@ -74,8 +76,8 @@ found """ +@add_metaclass(metafieldsform) class Form(AppObject): - __metaclass__ = metafieldsform __registry__ = 'forms' parent_form = None diff -r d394bfcd8c25 -r fa29f3628a1b web/htmlwidgets.py --- a/web/htmlwidgets.py Wed Sep 16 11:28:07 2015 +0200 +++ b/web/htmlwidgets.py Wed Sep 16 13:57:21 2015 +0200 @@ -24,6 +24,7 @@ import random from math import floor +from six import add_metaclass from six.moves import range from logilab.mtconverter import xml_escape @@ -117,9 +118,9 @@ self.w(u'') +@add_metaclass(class_deprecated) class SideBoxWidget(BoxWidget): """default CubicWeb's sidebox widget""" - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.10] class %(cls)s is deprecated' title_class = u'sideBoxTitle' @@ -209,9 +210,9 @@ self.w(u'') +@add_metaclass(class_deprecated) class BoxField(HTMLWidget): """couples label / value meant to be displayed in a box""" - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.10] class %(cls)s is deprecated' def __init__(self, label, value): self.label = label @@ -222,18 +223,19 @@ u'%s' % (self.label, self.value)) + +@add_metaclass(class_deprecated) class BoxSeparator(HTMLWidget): """a menu separator""" - __metaclass__ = class_deprecated __deprecation_warning__ = '[3.10] class %(cls)s is deprecated' def _render(self): self.w(u'