[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Initial zstd attempt
commit 7c09e7ec3d079a9295eea2ebe326c83569bde6b8
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sat Mar 31 19:58:31 2018 -0700
Initial zstd attempt
Doesn't yet properly decompress. Still figuring out this and lzma... :/
---
stem/descriptor/remote.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index ab61d3a7..9b71be8d 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -92,7 +92,7 @@ content. For example...
=============== ===========
**PLAINTEXT** Uncompressed data.
**GZIP** `GZip compression <https://www.gnu.org/software/gzip/>`_.
- **ZSTD** `Zstandard compression <https://www.zstd.net>`_
+ **ZSTD** `Zstandard compression <https://www.zstd.net>`_.
**LZMA** `LZMA compression <https://en.wikipedia.org/wiki/LZMA>`_.
=============== ===========
"""
@@ -132,7 +132,12 @@ try:
except ImportError:
LZMA_SUPPORTED = False
-ZSTD_SUPPORTED = False
+try:
+ # https://pypi.python.org/pypi/zstd
+ import zstd
+ ZSTD_SUPPORTED = True
+except ImportError:
+ ZSTD_SUPPORTED = False
Compression = stem.util.enum.Enum(
('PLAINTEXT', 'identity'),
@@ -528,8 +533,8 @@ class Query(object):
# https://stackoverflow.com/questions/3122145/zlib-error-error-3-while-decompressing-incorrect-header-check/22310760#22310760
data = zlib.decompress(data, zlib.MAX_WBITS | 32)
- elif encoding == Compression.ZSTD:
- pass # TODO: implement
+ elif encoding == Compression.ZSTD and ZSTD_SUPPORTED:
+ data = zstd.decompress(data)
elif encoding == Compression.LZMA and LZMA_SUPPORTED:
data = lzma.decompress(data)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits