|
6 | 6 | from future.builtins.disabled import * |
7 | 7 | from future.builtins import * |
8 | 8 | from future.standard_library import install_aliases |
| 9 | +from future.utils import raise_from |
9 | 10 | install_aliases() |
10 | | -from future.moves.collections import deque |
11 | | -from future.moves.itertools import zip_longest |
12 | | -from future.utils import with_metaclass |
13 | 11 | # pylint: enable=wildcard-import,unused-wildcard-import,wrong-import-order,wrong-import-position,import-error,no-name-in-module |
14 | 12 |
|
15 | 13 | # Standard lib imports |
@@ -67,26 +65,24 @@ def _cimgisproject(self): |
67 | 65 | supports_json_proj = hasattr(CIMGISProject, "FromJson") |
68 | 66 | supports_xml_proj = hasattr(CIMGISProject, "FromXml") |
69 | 67 |
|
70 | | - # check what type of GISProject file we have |
71 | | - zp = zipfile.Path(self._proj_zip) |
72 | | - if (zp / "GISProject.xml").exists(): |
73 | | - if supports_xml_proj: |
74 | | - self._cims["GISProject"] = CIMGISProject.FromXml(read_file_in_zip(self._proj_zip, "GISProject.xml")) |
75 | | - else: |
76 | | - raise NotImplementedError( |
77 | | - "This version of ArcGIS Pro does not support XML-based Projects, project file must be opened in ArcGIS Pro and saved to convert to internal JSON structure." |
78 | | - ) |
79 | | - elif (zp / "GISProject.json").exists(): |
| 68 | + # read project based on supported file type |
| 69 | + try: |
80 | 70 | if supports_json_proj: |
81 | 71 | self._cims["GISProject"] = CIMGISProject.FromJson( |
82 | 72 | read_file_in_zip(self._proj_zip, "GISProject.json") |
83 | 73 | ) |
| 74 | + elif supports_xml_proj: |
| 75 | + self._cims["GISProject"] = CIMGISProject.FromXml(read_file_in_zip(self._proj_zip, "GISProject.xml")) |
84 | 76 | else: |
85 | 77 | raise NotImplementedError( |
86 | | - "This version of ArcGIS Pro does not support JSON-based Projects, please upgrade your ArcGIS Pro install to open this project." |
| 78 | + "This version of ArcGIS Pro is unknown and supports neither XML-based or JSON-based CIM Project loading." |
87 | 79 | ) |
88 | | - else: |
89 | | - raise NotImplementedError("This is an unknown type of ArcGIS Pro project.") |
| 80 | + except KeyError as ke: |
| 81 | + raise_from( |
| 82 | + NotImplementedError( |
| 83 | + "This version of ArcGIS Pro does not support the type of Project you are attempting to open." |
| 84 | + ), ke |
| 85 | + ) |
90 | 86 |
|
91 | 87 | return self._cims["GISProject"] |
92 | 88 |
|
|
0 commit comments