Commit 51e5ec0e authored by Vincent A's avatar Vincent A

import with_metaclass from future or six

The syntax for using a metaclass is different in python2 and python3,
and there are existing helpers.

Add six as a dependency in
parent 03252146
......@@ -132,6 +132,7 @@ def install_weboob():
import Image
......@@ -51,7 +51,7 @@ except ImportError:
from weboob.exceptions import BrowserHTTPSDowngrade, ModuleInstallError
from import getLogger
from import basestring, unicode
from import basestring, unicode, with_metaclass
from import json
from .cookies import WeboobCookieJar
......@@ -614,7 +614,7 @@ class _PagesBrowserMeta(type):
return new_class
class PagesBrowser(DomainBrowser):
class PagesBrowser(with_metaclass(_PagesBrowserMeta, DomainBrowser)):
A browser which works pages and keep state of navigation.
......@@ -643,7 +643,6 @@ class PagesBrowser(DomainBrowser):
_urls = None
__metaclass__ = _PagesBrowserMeta
def __getattr__(self, name):
if self._urls is not None and name in self._urls:
......@@ -28,7 +28,7 @@ from copy import deepcopy
import lxml.html
from import getLogger, DEBUG_FILTERS
from import basestring, unicode
from import basestring, unicode, with_metaclass
from weboob.browser.pages import NextPage
from .filters.standard import _Filter, CleanText
......@@ -229,9 +229,7 @@ class _ItemElementMeta(type):
return new_class
class ItemElement(AbstractElement):
__metaclass__ = _ItemElementMeta
class ItemElement(with_metaclass(_ItemElementMeta, AbstractElement)):
_attrs = None
_loaders = None
klass = None
......@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <>.
from import basestring
from import basestring, with_metaclass
from .standard import _Filter, _NO_DEFAULT, Filter, ParseError
......@@ -36,9 +36,7 @@ class _DictMeta(type):
return cls(name)
class Dict(Filter):
__metaclass__ = _DictMeta
class Dict(with_metaclass(_DictMeta, Filter)):
def __init__(self, selector=None, default=_NO_DEFAULT):
super(Dict, self).__init__(self, default=default)
if selector is None:
......@@ -23,7 +23,7 @@ import re
from decimal import Decimal
from copy import deepcopy, copy
from import unicode, long
from import unicode, long, with_metaclass
from import to_unicode
......@@ -316,7 +316,7 @@ class _BaseObjectMeta(type):
return new_class
class BaseObject(object):
class BaseObject(with_metaclass(_BaseObjectMeta, object)):
This is the base class for a capability object.
......@@ -340,8 +340,6 @@ class BaseObject(object):
The docstring is mandatory.
__metaclass__ = _BaseObjectMeta
id = None
backend = None
url = StringField('url')
......@@ -18,7 +18,8 @@
# along with weboob. If not, see <>.
__all__ = ['unicode', 'long', 'basestring', 'check_output', 'range']
__all__ = ['unicode', 'long', 'basestring', 'check_output', 'range',
......@@ -44,3 +45,9 @@ except NameError:
from subprocess import check_output
from future.utils import with_metaclass
except ImportError:
from six import with_metaclass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment