Skip to content
Permalink
Browse files

Better creation of list of directories of a zip file. Fixes installat…

…ion problem with some plugins.

git-svn-id: http://svn.osgeo.org/qgis/trunk@8191 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Mar 6, 2008
1 parent 4b7a401 commit 244c451e0f608638a5f7ba4d6eda989c65b06c7a
Showing with 5 additions and 18 deletions.
  1. +5 −18 python/plugins/plugin_installer/qgis_plugins.py
@@ -95,24 +95,11 @@ def _listdirs(self, file):

dirs = []

for file in zf.filelist:
# It appears that all directories in a zip have a unique
# signature in the external_attr of the ZipInfo object.
# Shifting the external_attr by 28 will result in a value of 4
# for all directories. This is undocumented in the Python zipfile
# module but appears to be a solid way to identify directories
# in a zip file.
if file.external_attr >> 28 == 4:
dirs.append(file.filename)

if len(dirs) == 0:
# this means there is no top level directory in the
# zip file. We'll assume the first entry contains the
# directory and use it, hoping for the best...
entry = zf.namelist()[0]
dir = entry.split('/')[0]
dir += '/'
dirs.append(dir)
for name in zf.namelist():
(path, filename) = os.path.split(name)

if path not in dirs:
dirs.append(path)

dirs.sort()
return dirs

0 comments on commit 244c451

Please sign in to comment.
You can’t perform that action at this time.