diff --git a/meshroom/core/attribute.py b/meshroom/core/attribute.py index 79b940aeb3..4705f33dba 100644 --- a/meshroom/core/attribute.py +++ b/meshroom/core/attribute.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # coding:utf-8 -import collections import copy import re import weakref @@ -203,7 +202,7 @@ def getExportValue(self): def getValueStr(self): if isinstance(self.attributeDesc, desc.ChoiceParam) and not self.attributeDesc.exclusive: - assert(isinstance(self.value, collections.Sequence) and not isinstance(self.value, pyCompatibility.basestring)) + assert(isinstance(self.value, pyCompatibility.Sequence) and not isinstance(self.value, pyCompatibility.basestring)) return self.attributeDesc.joinChar.join(self.value) if isinstance(self.attributeDesc, (desc.StringParam, desc.File)): return '"{}"'.format(self.value) diff --git a/meshroom/core/desc.py b/meshroom/core/desc.py index 7196a45953..202b5f86f7 100755 --- a/meshroom/core/desc.py +++ b/meshroom/core/desc.py @@ -1,7 +1,6 @@ from meshroom.common import BaseObject, Property, Variant, VariantList from meshroom.core import pyCompatibility from enum import Enum # available by default in python3. For python2: "pip install enum34" -import collections import math import os import psutil @@ -230,7 +229,7 @@ def validateValue(self, value): if self.exclusive: return self.conformValue(value) - if not isinstance(value, collections.Iterable): + if not isinstance(value, pyCompatibility.Iterable): raise ValueError('Non exclusive ChoiceParam value should be iterable (param:{}, value:{}, type:{})'.format(self.name, value, type(value))) return [self.conformValue(v) for v in value] diff --git a/meshroom/core/pyCompatibility.py b/meshroom/core/pyCompatibility.py index b2483ee74e..50e9027138 100644 --- a/meshroom/core/pyCompatibility.py +++ b/meshroom/core/pyCompatibility.py @@ -13,3 +13,10 @@ unicode = unicode bytes = str basestring = basestring + +try: + # Import ABC from collections.abc in Python 3.4+ + from collections.abc import Sequence, Iterable +except ImportError: + # Import ABC from collections in Python 2 support + from collections import Sequence, Iterable