From 97d22fe67886a81cd8a6f96ce18a452080f9723b Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Fri, 11 Oct 2019 16:03:50 +1300 Subject: [PATCH] fix(Python 2): use a few aliases for exceptions * FileNotFoundError = IOError * ModuleNotFoundError = ImportError --- autotest/t011_test.py | 4 ++++ flopy/utils/gridintersect.py | 5 ++++- flopy/utils/mflistfile.py | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/autotest/t011_test.py b/autotest/t011_test.py index fadc34fc6e..7e6851f7cb 100644 --- a/autotest/t011_test.py +++ b/autotest/t011_test.py @@ -4,10 +4,14 @@ """ import os +import sys import flopy import numpy as np from nose.tools import raises +if sys.version_info[0] == 2: + FileNotFoundError = IOError + def test_mflistfile(): pth = os.path.join('..', 'examples', 'data', 'freyberg') diff --git a/flopy/utils/gridintersect.py b/flopy/utils/gridintersect.py index 6162798a53..a9dcb47de0 100644 --- a/flopy/utils/gridintersect.py +++ b/flopy/utils/gridintersect.py @@ -1,11 +1,14 @@ import numpy as np +import sys +if sys.version_info[0] == 2: + ModuleNotFoundError = ImportError from .geometry import transform try: from shapely.geometry import MultiPoint, Point, Polygon, box from shapely.strtree import STRtree from shapely.affinity import translate, rotate except ModuleNotFoundError: - print("Shapely is needed for grid intersect operations!" + print("Shapely is needed for grid intersect operations! " "Please install shapely.") diff --git a/flopy/utils/mflistfile.py b/flopy/utils/mflistfile.py index b336dbe0d7..105604a2c7 100644 --- a/flopy/utils/mflistfile.py +++ b/flopy/utils/mflistfile.py @@ -15,6 +15,9 @@ from ..utils.utils_def import totim_to_datetime +if sys.version_info[0] == 2: + FileNotFoundError = IOError + class ListBudget(object): """