How to use _unzip_file_entry method in localstack

Best Python code snippet using localstack_python

archives.py

Source:archives.py Github

copy

Full Screen

...27 zip_ref = zipfile.ZipFile(path, "r")28 except Exception as e:29 LOG.warning("Unable to open zip file: %s: %s", path, e)30 raise e31 def _unzip_file_entry(zip_ref, file_entry, target_dir):32 """Extracts a Zipfile entry and preserves permissions"""33 out_path = os.path.join(target_dir, file_entry.filename)34 if is_in_debian and os.path.exists(out_path) and os.path.getsize(out_path) > 0:35 # this can happen under certain circumstances if the native "unzip" command36 # fails with a non-zero exit code, yet manages to extract parts of the zip file37 return38 zip_ref.extract(file_entry.filename, path=target_dir)39 perm = file_entry.external_attr >> 1640 # Make sure to preserve file permissions in the zip file41 # https://www.burgundywall.com/post/preserving-file-perms-with-python-zipfile-module42 os.chmod(out_path, perm or 0o777)43 try:44 for file_entry in zip_ref.infolist():45 _unzip_file_entry(zip_ref, file_entry, target_dir)46 finally:47 zip_ref.close()48def untar(path: str, target_dir: str):49 mode = "r:gz" if path.endswith("gz") else "r"50 with tarfile.open(path, mode) as tar:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful