Skip to content

Commit

Permalink
Fix error while creating zip
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Jul 6, 2024
1 parent e17b19d commit 0a96f5b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@


def create_zip(files_to_zip):
with tempfile.TemporaryDirectory() as temp_dir:
zip_file = os.path.join(temp_dir, "function.zip")
with zipfile.ZipFile(zip_file, "w") as zipf:
for file in files_to_zip:
zipf.write(file, os.path.basename(file))
return zip_file
temp_dir = tempfile.TemporaryDirectory().name
os.makedirs(temp_dir)
zip_file = os.path.join(temp_dir, "function.zip")
with zipfile.ZipFile(zip_file, "w") as zipf:
for file in files_to_zip:
zipf.write(file, os.path.basename(file))
return zip_file


zip_path = create_zip(["main.py", "calculator.py", "requirements.txt"])
Expand Down

0 comments on commit 0a96f5b

Please sign in to comment.