Skip to content

Commit b1d9a5c

Browse files
Fixed issue that caused ProProject zip to be closed early
1 parent 3248566 commit b1d9a5c

31 files changed

+19
-23
lines changed

arcpyext/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "0.7.25"
1+
__version__ = "0.7.26"
22
__author__ = "David Whittingham; David Payne; Adam Kerz; Peter Reyne; Daniel Baternik; Chris Blanchfield; Gary Bagnall"
33
__copyright__ = "Copyright (C) 2013-2023 David Whittingham"

arcpyext/mapping/_cim/helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
# pylint: enable=wildcard-import,unused-wildcard-import,wrong-import-order,wrong-import-position,import-error,no-name-in-module
1212

1313

14-
def read_file_in_zip(zip_file, file_path, decode="utf-8"):
14+
def read_file_in_zip(zip_file_obj, inner_file_path, decode="utf-8"):
1515
"""Reads in an XML file as UTF-8 from a zip file."""
16-
with zip_file.open(file_path) as fp:
16+
with zip_file_obj.open(inner_file_path) as zip_file_handle:
1717
if decode:
18-
return fp.read().decode(decode)
18+
return zip_file_handle.read().decode(decode)
1919

20-
return fp.read()
20+
return zip_file_handle.read()
2121

2222

2323
def passthrough_prop(prop_name, doc=None, obj_name="_cim_obj"):

arcpyext/mapping/_cim/pro_project.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
from future.builtins.disabled import *
77
from future.builtins import *
88
from future.standard_library import install_aliases
9+
from future.utils import raise_from
910
install_aliases()
10-
from future.moves.collections import deque
11-
from future.moves.itertools import zip_longest
12-
from future.utils import with_metaclass
1311
# pylint: enable=wildcard-import,unused-wildcard-import,wrong-import-order,wrong-import-position,import-error,no-name-in-module
1412

1513
# Standard lib imports
@@ -67,26 +65,24 @@ def _cimgisproject(self):
6765
supports_json_proj = hasattr(CIMGISProject, "FromJson")
6866
supports_xml_proj = hasattr(CIMGISProject, "FromXml")
6967

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:
8070
if supports_json_proj:
8171
self._cims["GISProject"] = CIMGISProject.FromJson(
8272
read_file_in_zip(self._proj_zip, "GISProject.json")
8373
)
74+
elif supports_xml_proj:
75+
self._cims["GISProject"] = CIMGISProject.FromXml(read_file_in_zip(self._proj_zip, "GISProject.xml"))
8476
else:
8577
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."
8779
)
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+
)
9086

9187
return self._cims["GISProject"]
9288

Binary file not shown.
Binary file not shown.
50 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)