Skip to content

Commit 12b293f

Browse files
committed
feat: use zipfile
1 parent c2f79eb commit 12b293f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/generator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import shutil
3+
import zipfile
34
from pathlib import Path
45

56
from src.problem import Problem
@@ -54,4 +55,7 @@ def generate(self):
5455
self._logger.info("打包测试数据")
5556
path_zip = self._path / "testcase.zip"
5657
path_zip.unlink(missing_ok=True)
57-
os.system(f"7z a -tzip {path_zip} {PATH_TMP_FOLDER / '*.in'} {PATH_TMP_FOLDER / '*.out'}")
58+
with zipfile.ZipFile(path_zip, "w") as zip_file:
59+
for file in PATH_TMP_FOLDER.iterdir():
60+
if file.suffix in [".in", ".out"]:
61+
zip_file.write(file, file.name)

0 commit comments

Comments
 (0)