Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14155

LZMA Decompress - about LZMA properties

$
0
0

I'm writing code for parsing files compressed with the LZMA algorithm.

import lzmaimport structfrom bitio import bit_opendef main(file):  f = bit_open(file,'r')  magic = f.ReadString(8) # 8 Bytes  version = f.ReadInt()   # 4 Bytes  fileSize = f.ReadInt()  # 4 Bytes  props = f.byte_file.read(5) # 5 Bytes  dicSize = struct.unpack('<I', bytes(props[1:5]))[0]  d = props[0]  lc, d = divmod(d, 9)  pb, lp = divmod(d, 5)  filters=[    {"id": lzma.FILTER_LZMA2,"dict_size": dicSize,"lc": lc,"lp": lc,"pb": pb    }  ]  decompressor = lzma.LZMADecompressor(      format=lzma.FORMAT_RAW,      filters=filters  )  myData = f.byte_file.read()  result = decompressor.decompress(myData)  print(result)

This is my code.

I didn't get an error when I run the code, code print just

b''

I already checked variable myData and it contains compressed data.

Is there a problem with using the Specifying custom filter chains?
or how can I change my code to input the LZMA properties?


Viewing all articles
Browse latest Browse all 14155

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>