-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzip_code.py
24 lines (20 loc) · 948 Bytes
/
zip_code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from zipfile import ZipFile
import os
from os.path import basename
excluded_directories = ['000_practice', 'input_data', 'runs', 'submissions', '__pycache__', 'venv']
def zip_code():
# create a ZipFile object
with ZipFile('submission/code.zip', 'w') as zipObj:
# Iterate over all the files in directory
for folderName, subfolders, filenames in os.walk('.'):
for filename in filenames:
# Skip non python/json files
if '.py' not in filename and '.json' not in filename:
continue
# Skip excluded directories
if any(directory in folderName for directory in excluded_directories):
continue
# create complete filepath of file in directory
filePath = os.path.join(folderName, filename)
# Add file to zip
zipObj.write(filePath, basename(filePath))