diff options
author | gandalf3 <gandalf3@blendermonkey.com> | 2017-08-29 10:05:41 +0300 |
---|---|---|
committer | gandalf3 <gandalf3@blendermonkey.com> | 2017-08-29 10:05:41 +0300 |
commit | 6c3786713e4b74d1abadbdc74d955ae2171aa520 (patch) | |
tree | 74e457723acd8a54a69116b181d3a60c78a66acb /release | |
parent | 90ea56b2fbb8aa0a14e44e075085767c309db754 (diff) |
Split code for installing zipped and unzipped packages into separate functions
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bpkg/actions.py | 18 |
1 files changed, 10 insertions, 8 deletions
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") |