Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import ABC from collections.abc #983

Merged
merged 3 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions meshroom/core/attribute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# coding:utf-8
import collections
import copy
import re
import weakref
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions meshroom/core/desc.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]

Expand Down
7 changes: 7 additions & 0 deletions meshroom/core/pyCompatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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