[Bf-blender-cvs] [6c3786713e4] soc-2017-package_manager: Split code for installing zipped and unzipped packages into separate functions
gandalf3
noreply at git.blender.org
Tue Aug 29 11:46:16 CEST 2017
Commit: 6c3786713e4b74d1abadbdc74d955ae2171aa520
Author: gandalf3
Date: Tue Aug 29 00:05:41 2017 -0700
Branches: soc-2017-package_manager
https://developer.blender.org/rB6c3786713e4b74d1abadbdc74d955ae2171aa520
Split code for installing zipped and unzipped packages into separate functions
===================================================================
M release/scripts/modules/bpkg/actions.py
===================================================================
diff --git a/release/scripts/modules/bpkg/actions.py b/release/scripts/modules/bpkg/actions.py
index bc625f0aab2..5352725cdeb 100644
--- a/release/scripts/modules/bpkg/actions.py
+++ b/release/scripts/modules/bpkg/actions.py
@@ -86,13 +86,10 @@ def install(src_file: Path, dest_dir: Path):
# TODO: check to make sure addon/package isn't already installed elsewhere
- # The following is adapted from `addon_install` in bl_operators/wm.py
-
- # check to see if the file is in compressed format (.zip)
- if zipfile.is_zipfile(str(src_file)):
- log.debug("Package is zipfile")
+ def install_zip(src_zip, dest_dir):
+ """Extract src_zip to dest_dir"""
try:
- file_to_extract = zipfile.ZipFile(str(src_file), 'r')
+ file_to_extract = zipfile.ZipFile(str(src_zip), 'r')
except Exception as err:
raise exceptions.InstallException("Failed to read zip file: %s" % err) from err
@@ -122,8 +119,8 @@ def install(src_file: Path, dest_dir: Path):
for backup in backups:
backup.remove()
- else:
- log.debug("Package is pyfile")
+ def install_py(src_file, dest_dir):
+ """Move src_file to dest_dir)"""
dest_file = (dest_dir / src_file.name)
backup = None
@@ -139,4 +136,9 @@ def install(src_file: Path, dest_dir: Path):
if backup:
backup.remove()
+ if zipfile.is_zipfile(str(src_file)):
+ install_zip(src_file, dest_dir)
+ else:
+ install_py(src_file, dest_dir)
+
log.debug("Installation succeeded")
More information about the Bf-blender-cvs
mailing list