summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xexamples/chroottar.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/chroottar.py b/examples/chroottar.py
index d229956..49d9a7d 100755
--- a/examples/chroottar.py
+++ b/examples/chroottar.py
@@ -31,12 +31,11 @@ class TarFile(tarfile.TarFile):
cls,
name: str,
mode: typing.Literal["r", "w", "x"] = "r",
- fileobj: None = None,
+ fileobj: typing.BinaryIO | None = None,
) -> tarfile.TarFile:
if mode not in ("r", "w", "x"):
raise NotImplementedError(f"mode `{mode}' not implemented for zst")
- if fileobj is not None:
- raise NotImplementedError("zst does not support a fileobj")
+ openobj: str | typing.BinaryIO = name if fileobj is None else fileobj
try:
import zstandard
except ImportError as err:
@@ -44,10 +43,10 @@ class TarFile(tarfile.TarFile):
"zstandard module not available"
) from err
if mode == "r":
- zfobj = zstandard.open(name, "rb")
+ zfobj = zstandard.open(openobj, "rb")
else:
zfobj = zstandard.open(
- name,
+ openobj,
mode + "b",
cctx=zstandard.ZstdCompressor(write_checksum=True, threads=-1),
)