Skip to content

Commit

Permalink
Only add tar filter flag on Python >= 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed Sep 4, 2024
1 parent d71fb9f commit 006f979
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cesium/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib
import errno
import os
import sys
import tarfile
import tempfile
import zipfile
Expand Down Expand Up @@ -88,7 +89,8 @@ def extract_time_series(
x for x in archive.getmembers() if not x.name.startswith((".", "/"))
]
extracted_names = [x.name for x in members_to_extract]
archive.extractall(path=extract_dir, members=members_to_extract, filter="data")
kwds = {"filter": "data"} if sys.version_info[:2] >= (3, 12) else {}
archive.extractall(path=extract_dir, members=members_to_extract, **kwds)
all_paths = [os.path.join(extract_dir, f) for f in extracted_names]
elif zipfile.is_zipfile(data_path):
archive = zipfile.ZipFile(data_path)
Expand Down

0 comments on commit 006f979

Please sign in to comment.