Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
JOSSOUD Olivier
WIM Collect
Commits
1f5f33a0
Commit
1f5f33a0
authored
Jan 24, 2020
by
JOSSOUD Olivier
Browse files
Utils. Bug correction. Was trying to deleted already-deleted temp file.
parent
ab00eab8
Pipeline
#57256
passed with stages
in 1 minute and 1 second
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
wimcollect/utils.py
wimcollect/utils.py
+22
-7
No files found.
wimcollect/utils.py
View file @
1f5f33a0
...
...
@@ -36,7 +36,24 @@ def get_config_parser() -> configobj.ConfigObj:
return
config_parser
def
recompress_file
(
zip_filepath
:
str
):
def
recompress_file
(
zip_filepath
:
str
)
->
str
:
"""Recompress archive file in LZMA.
LZMA compression algorithm produces smaller files than usual ZIP, and the decompression is faster.
This function is useful for converting ZIP files from external sources into LZMA file.
Parameters
----------
zip_filepath: str
Full file path of the source ZIP file.
Returns
-------
str
Full file path of the LZMA-compressed output file. Basically the same as `zip_filepath`, with `.zip` replaced
by `.lzma`.
"""
# Directory where the original ZIP is, where the ZIP content will temporarily be extracted and where the final
# LZMA file will be created.
current_directory
=
os
.
path
.
dirname
(
zip_filepath
)
...
...
@@ -54,12 +71,10 @@ def recompress_file(zip_filepath: str):
zipf
.
write
(
filepath
,
arcname
=
os
.
path
.
basename
(
filepath
))
zipf
.
close
()
if
os
.
path
.
exists
(
compressed_filepath
):
for
file
in
files_in_zip
:
os
.
remove
(
file
)
return
compressed_filepath
else
:
return
None
if
not
os
.
path
.
exists
(
compressed_filepath
):
raise
Exception
(
"Failed to recompress "
+
zip_filepath
)
return
compressed_filepath
def
extract_compressed_file
(
compressed_filepath
:
str
,
dest_dir
:
str
,
delete_compressed
:
bool
=
False
)
->
list
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment