Commit 1f5f33a0 authored by JOSSOUD Olivier's avatar 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
......@@ -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.
zip_filepath: str
Full file path of the source ZIP file.
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))
if os.path.exists(compressed_filepath):
for file in files_in_zip:
return compressed_filepath
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:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment