-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Select between native and Python implementations of lz4 and lzo
Two new extra's "lz4" and "lzo" are defined which will install the needed Python packages to do naitve lz4 and lzo decompression. When installed the dissect.util.compression.lz4 and dissect.util.compression.lzo modules will point to these native versions. Otherwise they will point to the pure Python implementations in this project. The native (when available) and Python modules can be accessed explicitly through: - dissect.util.compression.lz4_native - dissect.util.compression.lz4_python - dissect.util.compression.lzo_native - dissect.util.compression.lzo_python
- Loading branch information
Showing
4 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from dissect.util.compression import lz4 as lz4_python | ||
from dissect.util.compression import lzo as lzo_python | ||
|
||
# This selects between the native version of lz4 (when installed) and our own | ||
# pure-Python implementation. | ||
# | ||
# By doing a: | ||
# from dissect.util.compression import lz4 | ||
# | ||
# in another project will automatically give you one or the other. | ||
# | ||
# The native version is also available as dissect.util.compression.lz4_native | ||
# (when installed) and the pure Python version is always available as | ||
# dissect.util.compression.lz4_python. | ||
# | ||
# Note that the pure Python implementation is not a full replacement of the | ||
# native lz4 Python package: only the decompress() function is implemented. | ||
try: | ||
import lz4.block as lz4 | ||
import lz4.block as lz4_native | ||
except ImportError: | ||
lz4 = lz4_python | ||
lz4_native = None | ||
|
||
# This selects between the native version of lzo (when installed) and our own | ||
# pure-Python implementation. | ||
# | ||
# By doing a: | ||
# from dissect.util.compression import lzo | ||
# | ||
# in another project will automatically give you one or the other. | ||
# | ||
# The native version is also available as dissect.util.compression.lzo_native | ||
# (when installed) and the pure Python version is always available as | ||
# dissect.util.compression.lzo_python. | ||
# | ||
# Note that the pure Python implementation is not a full replacement of the | ||
# native lzo Python package: only the decompress() function is implemented. | ||
try: | ||
import lzo | ||
import lzo as lzo_native | ||
except ImportError: | ||
lzo = lzo_python | ||
lzo_native = None | ||
|
||
__all__ = [ | ||
"lz4", | ||
"lz4_native", | ||
"lz4_python", | ||
"lznt1", | ||
"lzo", | ||
"lzo_native", | ||
"lzo_python", | ||
"lzxpress", | ||
"lzxpress_huffman", | ||
"sevenbit", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters