def __decompress_string(cls, string, compressions=None):
# type: (Any, bytes, Union[None, Iterable[int]]) -> Tuple[bytes, bool]
"""Returns a tuple containing the decompressed :py:class:`bytes` and a
:py:class:`bool` as to whether decompression failed or not
Args:
string: The possibly-compressed message you wish to parse
compressions: A list of the standard compression methods this
message may be under (default: ``[]``)
Returns:
A decompressed version of the message
Raises:
ValueError: Unrecognized compression method fed in compressions
Warning:
Do not feed it with the size header, it will throw errors
"""
compression_fail = False
# second is module scope compression
for method in intersect(compressions, compression):
try:
string = decompress(string, method)
compression_fail = False
break
except:
compression_fail = True
continue
return (string, compression_fail)
评论列表
文章目录