Skip to content

Commit

Permalink
Change ocen archive to zip (#181)
Browse files Browse the repository at this point in the history
* Change ocen archive to zip

* Bump version
  • Loading branch information
MasloMaslane authored Feb 13, 2024
1 parent 70974ff commit c1367e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/sinol_make/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sinol_make import util, oiejq


__version__ = "1.5.23"
__version__ = "1.5.24"


def configure_parsers():
Expand Down
3 changes: 1 addition & 2 deletions src/sinol_make/commands/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ def create_ocen(self, target_dir: str):
glob.glob(os.path.join(tests_dir, ext, f'{self.task_id}*ocen.{ext}')):
shutil.copy(test, os.path.join(ocen_dir, ext, os.path.basename(test)))

with tarfile.open(os.path.join(attachments_dir, f'{self.task_id}ocen.tgz'), "w:gz") as tar:
tar.add(ocen_dir, arcname=os.path.basename(ocen_dir))
shutil.make_archive(os.path.join(attachments_dir, f'{self.task_id}ocen'), 'zip', tmpdir)

def copy_package_required_files(self, target_dir: str):
"""
Expand Down
9 changes: 5 additions & 4 deletions tests/commands/export/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import glob
import pytest
import tarfile
import zipfile
import tempfile

from sinol_make import configure_parsers
Expand Down Expand Up @@ -153,12 +154,12 @@ def test_ocen_archive(create_package):
tests = [os.path.basename(f) for f in glob.glob(os.path.join(package_path, ext, f'*.{ext}'))]
assert set(tests) == set(in_handwritten if ext == "in" else out_handwritten)

ocen_tar = os.path.join(package_path, "attachments", f"{task_id}ocen.tgz")
assert os.path.exists(ocen_tar)
ocen_archive = os.path.join(package_path, "attachments", f"{task_id}ocen.zip")
assert os.path.exists(ocen_archive)
ocen_dir = os.path.join(package_path, "ocen_dir")

with tarfile.open(ocen_tar, "r") as tar:
sinol_util.extract_tar(tar, ocen_dir)
with zipfile.ZipFile(ocen_archive, "r") as zip:
zip.extractall(ocen_dir)

for ext in ["in", "out"]:
tests = [os.path.basename(f) for f in glob.glob(os.path.join(ocen_dir, task_id, ext, f'*.{ext}'))]
Expand Down

0 comments on commit c1367e7

Please sign in to comment.