Skip to content

Commit 6f94559

Browse files
Merge pull request #250 from bva-bme/master
Added uppercase file extension compatibility for zip files
2 parents 66ae197 + 0b30ea1 commit 6f94559

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

shapefile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ def __init__(self, *args, **kwargs):
982982
# Inspect zipfile contents to find the full shapefile path
983983
shapefiles = [name
984984
for name in archive.namelist()
985-
if name.endswith('.shp')]
985+
if (name.endswith('.SHP') or name.endswith('.shp'))]
986986
# The zipfile must contain exactly one shapefile
987987
if len(shapefiles) == 0:
988988
raise ShapefileException('Zipfile does not contain any shapefiles')
@@ -993,14 +993,14 @@ def __init__(self, *args, **kwargs):
993993
path to the shapefile you would like to open.' % shapefiles )
994994
# Try to extract file-like objects from zipfile
995995
shapefile = os.path.splitext(shapefile)[0] # root shapefile name
996-
for ext in ['shp','shx','dbf']:
996+
for ext in ['SHP','SHX','DBF','shp','shx','dbf']:
997997
try:
998998
member = archive.open(shapefile+'.'+ext)
999999
# write zipfile member data to a read+write tempfile and use as source, gets deleted on close()
10001000
fileobj = tempfile.NamedTemporaryFile(mode='w+b', delete=True)
10011001
fileobj.write(member.read())
10021002
fileobj.seek(0)
1003-
setattr(self, ext, fileobj)
1003+
setattr(self, ext.lower(), fileobj)
10041004
self._files_to_close.append(fileobj)
10051005
except:
10061006
pass

0 commit comments

Comments
 (0)