Skip to content

Commit 2ef17f0

Browse files
author
wonder
committedMar 6, 2008
Better creation of list of directories of a zip file. Fixes installation problem with some plugins.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8191 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2a4f4bf commit 2ef17f0

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed
 

‎python/plugins/plugin_installer/qgis_plugins.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,11 @@ def _listdirs(self, file):
9595

9696
dirs = []
9797

98-
for file in zf.filelist:
99-
# It appears that all directories in a zip have a unique
100-
# signature in the external_attr of the ZipInfo object.
101-
# Shifting the external_attr by 28 will result in a value of 4
102-
# for all directories. This is undocumented in the Python zipfile
103-
# module but appears to be a solid way to identify directories
104-
# in a zip file.
105-
if file.external_attr >> 28 == 4:
106-
dirs.append(file.filename)
107-
108-
if len(dirs) == 0:
109-
# this means there is no top level directory in the
110-
# zip file. We'll assume the first entry contains the
111-
# directory and use it, hoping for the best...
112-
entry = zf.namelist()[0]
113-
dir = entry.split('/')[0]
114-
dir += '/'
115-
dirs.append(dir)
98+
for name in zf.namelist():
99+
(path, filename) = os.path.split(name)
100+
101+
if path not in dirs:
102+
dirs.append(path)
116103

117104
dirs.sort()
118105
return dirs

0 commit comments

Comments
 (0)
Please sign in to comment.