Skip to content

Commit 7404bbb

Browse files
author
gsherman
committed
Removal of dead code and explanation of the method for determining which directories are contained in the zip file of the plugin
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7971 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 40ea025 commit 7404bbb

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

python/plugins/plugin_installer/qgis_plugins.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,19 @@ def _listdirs(self, file):
9090
dirs = []
9191

9292
for file in zf.filelist:
93+
# It appears that all directories in a zip have a unique
94+
# signature in the external_attr of the ZipInfo object.
95+
# Shifting the external_attr by 28 will result in a value of 4
96+
# for all directories. This is undocumented in the Python zipfile
97+
# module but appears to be a solid way to identify directories
98+
# in a zip file.
9399
if file.external_attr >> 28 == 4:
94-
# print "Adding %s to the list of directories to create" % file.filename
95100
dirs.append(file.filename)
96101

97-
#for name in zf.namelist():
98-
# if name.endswith('/'):
99-
# dirs.append(name)
100-
101-
## Check for subdirectories by assuming a file with length 0
102-
## is a directory (this isn't necessarily true but it allows
103-
## plugins with subdirectories to be installed)
104-
#for file in zf.filelist:
105-
# if file.file_size == 0:
106-
# dirs.append(file.file_name)
107-
108-
109102
if len(dirs) == 0:
110103
# this means there is no top level directory in the
111104
# zip file. We'll assume the first entry contains the
112-
# directory and use it
105+
# directory and use it, hoping for the best...
113106
entry = zf.namelist()[0]
114107
dir = entry.split('/')[0]
115108
dir += '/'

0 commit comments

Comments
 (0)