Skip to content

Commit 3305d3f

Browse files
committed
✨ Add compression
1 parent 8f7f1b6 commit 3305d3f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

exec_code.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from RestrictedPython import compile_restricted, RestrictingNodeTransformer
55
from contextlib import redirect_stdout
6+
from zipfile import ZipFile
7+
68
import sys
79
import os
810
import shutil
@@ -56,8 +58,14 @@ def run_code(project_name: str):
5658
input_file = os.path.join('input', input_file_name)
5759
execute_file(input_file, 'code.py', out_file, project_name)
5860
print('=' * 100)
59-
print(f'----> Project {repr(project_name)} done.')
61+
print(f'----> Project {repr(project_name)} done. Compressing...')
62+
63+
with ZipFile('tests_cases.zip', mode='w') as zip_:
64+
for folder in ['input', 'output']:
65+
for file_ in os.listdir(folder):
66+
zip_.write(os.path.join(folder, file_), os.path.join(folder, file_))
6067
os.chdir(os.path.join('..', '..'))
68+
print(f'----> Project {repr(project_name)} compressed.')
6169

6270

6371
def main():

0 commit comments

Comments
 (0)