Skip to content

Commit

Permalink
add skip argument to extract_archive
Browse files Browse the repository at this point in the history
  • Loading branch information
SiQube committed Dec 5, 2024
1 parent 99008e8 commit 4f4f0ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pymovements/utils/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def _extract_tar(
source_path: Path,
destination_path: Path,
compression: str | None,
skip: bool = True,
) -> None:
"""Extract a tar archive.
Expand All @@ -149,13 +150,16 @@ def _extract_tar(
Path to the directory the file will be extracted to.
compression: str | None
Compression filename suffix.
skip: bool
Skip already extracted files. (default: True)
"""
with tarfile.open(source_path, f'r:{compression[1:]}' if compression else 'r') as archive:
for member in archive.getnames():
if (
os.path.exists(os.path.join(destination_path, member)) and
member[-4:] not in _ARCHIVE_EXTRACTORS and
tarfile.TarInfo(os.path.join(destination_path, member)).size > 0
tarfile.TarInfo(os.path.join(destination_path, member)).size > 0 and
skip
):
continue

Check warning on line 164 in src/pymovements/utils/archives.py

View check run for this annotation

Codecov / codecov/patch

src/pymovements/utils/archives.py#L164

Added line #L164 was not covered by tests
if sys.version_info < (3, 12): # pragma: <3.12 cover
Expand Down

0 comments on commit 4f4f0ff

Please sign in to comment.