Skip to content

Commit 1153e78

Browse files
committed
switch import of mapping between python versions
1 parent abd62a7 commit 1153e78

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
496496
* Added `kwargs` to all child classes of `compas.data.Data`.
497497
* Added grasshopper component for drawing a frame.
498498
* Added `draw_origin` and `draw_axes`.
499+
* Added `compas.PY2`.
499500

500501
### Changed
501502

src/compas/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
Float formatting (``'<x>f'``) and integer formatting (``'d'``) specifiers are supported.
7777
"""
7878

79+
PY2 = compas._os.PY2
80+
"""bool: True if the current Python version is 2.x, False otherwise."""
81+
7982
PY3 = compas._os.PY3
8083
"""bool: True if the current Python version is 3.x, False otherwise."""
8184

src/compas/_os.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
class NotADirectoryError(Exception):
1818
pass
1919

20+
PY2 = sys.version_info[0] == 2
2021
PY3 = sys.version_info[0] == 3
2122
SYMLINK_REGEX = re.compile(r"\n.*\<SYMLINKD\>\s(.*)\s\[(.*)\]\r")
2223

src/compas/artists/colordict.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import compas
12
from collections import defaultdict
2-
from collections import Mapping
3+
if compas.PY2:
4+
from collections import Mapping
5+
else:
6+
from collections.abc import Mapping
37
from compas.colors import Color
48

59

0 commit comments

Comments
 (0)