Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
QgsPluginInstaller can now read zipfiles where 1st internal file is l…
…ocated in plugin subfolder
  • Loading branch information
jakimowb committed Feb 25, 2021
1 parent 984e0b1 commit 048af49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/pyplugin_installer/installer.py
Expand Up @@ -570,8 +570,13 @@ def installFromZipFile(self, filePath):
settings.setValue(settingsGroup + '/lastZipDirectory',
QFileInfo(filePath).absoluteDir().absolutePath())

pluginName = None
with zipfile.ZipFile(filePath, 'r') as zf:
pluginName = os.path.split(zf.namelist()[0])[0]
# search for metadata.txt. In case of multiple files, we can assume that
# the shortest path relates <pluginname>/metadata.txt
metadatafiles = sorted(f for f in zf.namelist() if f.endswith('metadata.txt'))
if len(metadatafiles) > 0:
pluginName = os.path.split(metadatafiles[0])[0]

pluginFileName = os.path.splitext(os.path.basename(filePath))[0]

Expand Down

0 comments on commit 048af49

Please sign in to comment.