in aws_lambda_builders/workflows/dotnet_clipackage/utils.py [0:0]
def unzip(self, zip_file_path, output_dir, permission=None):
"""
This method and dependent methods were copied from SAM CLI, but with the addition of deleting the zip file
https://github.com/aws/aws-sam-cli/blob/458076265651237a662a372f54d5b3df49fd6797/samcli/local/lambdafn/zip.py#L81
Unzip the given file into the given directory while preserving file permissions in the process.
Parameters
----------
zip_file_path : str
Path to the zip file
output_dir : str
Path to the directory where the it should be unzipped to
permission : int
Permission to set in an octal int form
"""
with zipfile.ZipFile(zip_file_path, "r") as zip_ref:
# For each item in the zip file, extract the file and set permissions if available
for file_info in zip_ref.infolist():
extracted_path = self._extract(file_info, output_dir, zip_ref)
# If the extracted_path is a symlink, do not set the permissions. If the target of the symlink does not
# exist, then os.chmod will fail with FileNotFoundError
if not os.path.islink(extracted_path):
self._set_permissions(file_info, extracted_path)
self._override_permissions(extracted_path, permission)
if not os.path.islink(extracted_path):
self._override_permissions(output_dir, permission)
os.remove(zip_file_path)