Commit 754db1d9 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

*: import from collections.abc on python3

parent bee4b91b
...@@ -34,8 +34,14 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool ...@@ -34,8 +34,14 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Acquisition import aq_base from Acquisition import aq_base
from six.moves import UserDict from six.moves import UserDict
import collections
import six import six
# pylint:disable=import-error,no-name-in-module
if six.PY3:
import collections.abc as collections_abc
else:
import collections as collections_abc
# pylint:enable=import-error,no-name-in-module
# the ERP5 cache factory used as a storage # the ERP5 cache factory used as a storage
SESSION_CACHE_FACTORY = 'erp5_session_cache' SESSION_CACHE_FACTORY = 'erp5_session_cache'
...@@ -54,11 +60,11 @@ def remove_acquisition_wrapper(obj): ...@@ -54,11 +60,11 @@ def remove_acquisition_wrapper(obj):
if isinstance(obj, basestring): if isinstance(obj, basestring):
return obj return obj
obj = aq_base(obj) obj = aq_base(obj)
if isinstance(obj, collections.Mapping): if isinstance(obj, collections_abc.Mapping):
return obj.__class__({ return obj.__class__({
remove_acquisition_wrapper(k): remove_acquisition_wrapper(v) remove_acquisition_wrapper(k): remove_acquisition_wrapper(v)
for k, v in obj.items()}) for k, v in obj.items()})
if isinstance(obj, (collections.Sequence, collections.Set)): if isinstance(obj, (collections_abc.Sequence, collections_abc.Set)):
return obj.__class__([remove_acquisition_wrapper(o) for o in obj]) return obj.__class__([remove_acquisition_wrapper(o) for o in obj])
return obj return obj
...@@ -68,11 +74,11 @@ def restore_acquisition_wrapper(obj, context): ...@@ -68,11 +74,11 @@ def restore_acquisition_wrapper(obj, context):
return obj return obj
if hasattr(obj, '__of__'): if hasattr(obj, '__of__'):
obj = obj.__of__(context) obj = obj.__of__(context)
if isinstance(obj, collections.Mapping): if isinstance(obj, collections_abc.Mapping):
return obj.__class__({ return obj.__class__({
restore_acquisition_wrapper(k, context): restore_acquisition_wrapper(v, context) restore_acquisition_wrapper(k, context): restore_acquisition_wrapper(v, context)
for k, v in obj.items()}) for k, v in obj.items()})
if isinstance(obj, (collections.Sequence, collections.Set)): if isinstance(obj, (collections_abc.Sequence, collections_abc.Set)):
return obj.__class__([restore_acquisition_wrapper(o, context) for o in obj]) return obj.__class__([restore_acquisition_wrapper(o, context) for o in obj])
return obj return obj
......
...@@ -27,8 +27,12 @@ ...@@ -27,8 +27,12 @@
############################################################################## ##############################################################################
import warnings import warnings
from collections import Mapping import six
from collections import Iterable if six.PY3:
from collections.abc import Iterable, Mapping
else:
from collections import Iterable, Mapping
try: try:
from deepdiff import DeepDiff from deepdiff import DeepDiff
from deepdiff.helper import strings, numbers from deepdiff.helper import strings, numbers
......
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