Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(export): use "7zip" format to export a study
Browse files Browse the repository at this point in the history
laurent-laporte-pro authored and mabw-rte committed Apr 23, 2024
1 parent b4948ca commit 9b105ac
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions antarest/study/storage/rawstudy/raw_study_service.py
Original file line number Diff line number Diff line change
@@ -128,21 +128,19 @@ def update_name_and_version_from_raw_meta(self, metadata: RawStudy) -> bool:

def exists(self, study: RawStudy) -> bool:
"""
Check study exist.
Check if the study exists in the filesystem.
Args:
study: study
study: The study to check.
Returns: true if study presents in disk, false else.
"""
path = self.get_study_path(study)

if study.archived:
path = self.get_archive_path(study)
zf = ZipFile(path, "r")
return str("study.antares") in zf.namelist()
archive_path = self.get_archive_path(study)
return archive_path.is_file()

return (path / "study.antares").is_file()
path = self.get_study_path(study)
return path.joinpath("study.antares").is_file()

def get_raw(
self,
@@ -392,7 +390,21 @@ def unarchive(self, study: RawStudy) -> None:
self.import_study(study, fh)

def get_archive_path(self, study: RawStudy) -> Path:
return Path(self.config.storage.archive_dir / f"{study.id}.zip")
"""
Get archive path of a study.
Args:
study: The study to get the archive path for.
Returns:
The full path of the archive file (zip or 7z).
"""
archive_dir: Path = self.config.storage.archive_dir
for suffix in [".zip", ".7z"]:
path = archive_dir.joinpath(f"{study.id}{suffix}")
if path.is_file():
return path
return archive_dir.joinpath(f"{study.id}.7z")

def get_study_path(self, metadata: Study) -> Path:
"""

0 comments on commit 9b105ac

Please sign in to comment.