@@ -134,6 +134,7 @@ def bytes(s, encoding):
134
134
PROPERTY_DUMMY = unhexlify ('19' ) # '\x19'
135
135
136
136
COMPRESSION_METHOD_COPY = unhexlify ('00' ) # '\x00'
137
+ COMPRESSION_METHOD_DELTA = unhexlify ('03' ) # '\x03'
137
138
COMPRESSION_METHOD_LZMA = unhexlify ('030101' ) # '\x03\x01\x01'
138
139
COMPRESSION_METHOD_CRYPTO = unhexlify ('06' ) # '\x06'
139
140
COMPRESSION_METHOD_MISC = unhexlify ('04' ) # '\x04'
@@ -605,6 +606,7 @@ def __init__(self, info, start, src_start, folder, archive, maxsize=None):
605
606
self .reset ()
606
607
self ._decoders = {
607
608
COMPRESSION_METHOD_COPY : '_read_copy' ,
609
+ COMPRESSION_METHOD_DELTA : '_read_delta' ,
608
610
COMPRESSION_METHOD_LZMA : '_read_lzma' ,
609
611
COMPRESSION_METHOD_LZMA2 : '_read_lzma2' ,
610
612
COMPRESSION_METHOD_MISC_ZIP : '_read_zip' ,
@@ -653,7 +655,17 @@ def _read_copy(self, coder, input, level, num_coders):
653
655
self ._file .seek (self ._src_start )
654
656
input = self ._file .read (size )
655
657
return input [self ._start :self ._start + size ]
656
-
658
+
659
+ def _read_delta (self , coder , input , level , num_coders ):
660
+ size = self ._uncompressed [level ]
661
+ if not input :
662
+ self ._file .seek (self ._src_start )
663
+ input = self ._file .read (size )
664
+ assert len (coder ['properties' ]) == 1
665
+ delta = ord (coder ['properties' ]) + 1
666
+ data = pylzma .delta_decode (input , delta )
667
+ return data [self ._start :self ._start + size ]
668
+
657
669
def _read_from_decompressor (self , coder , decompressor , input , level , num_coders , can_partial_decompress = True , with_cache = False ):
658
670
size = self ._uncompressed [level ]
659
671
data = ''
0 commit comments