diff options
author | Helmut Grohne <helmut@subdivi.de> | 2023-05-25 22:53:27 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2023-05-26 00:04:43 +0200 |
commit | a7a7cd476fddfe84de1467a96d8cfad5843db09b (patch) | |
tree | 65cecfc006ec3c6e13c6addce49511a080a8691b | |
parent | 924f0c734a7accb87e2ac911cee6e24dd463f237 (diff) | |
download | debian-dedup-a7a7cd476fddfe84de1467a96d8cfad5843db09b.tar.gz |
support zstd as a decompressor
-rw-r--r-- | dedup/compression.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/dedup/compression.py b/dedup/compression.py index 2e9869c..742d7fd 100644 --- a/dedup/compression.py +++ b/dedup/compression.py @@ -5,6 +5,11 @@ import zlib import lzma +try: + import zstandard +except ImportError: + zstandard = None + class Decompressor(typing.Protocol): def copy(self) -> "Decompressor": @@ -196,6 +201,10 @@ decompressors = { '.xz': lzma.LZMADecompressor, } +if zstandard is not None: + decompressors[".zst"] = zstandard.ZstdDecompressor + + def decompress(filelike: typing.BinaryIO, extension: str) -> typing.BinaryIO: """Decompress a stream according to its extension. @param filelike: is a read-only byte-stream. It must support read(size) and |