/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tuned_gzip.py

  • Committer: Jelmer Vernooij
  • Date: 2020-05-06 02:13:25 UTC
  • mfrom: (7490.7.21 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200506021325-awbmmqu1zyorz7sj
Merge 3.1 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Legacy breezy specific gzip tunings."""
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
20
import struct
23
21
import zlib
24
22
 
41
39
 
42
40
 
43
41
def chunks_to_gzip(chunks, factory=zlib.compressobj,
44
 
    level=zlib.Z_DEFAULT_COMPRESSION, method=zlib.DEFLATED,
45
 
    width=-zlib.MAX_WBITS, mem=zlib.DEF_MEM_LEVEL,
46
 
    crc32=zlib.crc32):
 
42
                   level=zlib.Z_DEFAULT_COMPRESSION, method=zlib.DEFLATED,
 
43
                   width=-zlib.MAX_WBITS, mem=zlib.DEF_MEM_LEVEL,
 
44
                   crc32=zlib.crc32):
47
45
    """Create a gzip file containing chunks and return its content.
48
46
 
49
47
    :param chunks: An iterable of strings. Each string can have arbitrary
61
59
        b'\002'      # self.fileobj.write('\002')
62
60
        b'\377'      # self.fileobj.write('\377')
63
61
                     # if fname:
64
 
        b''          #     self.fileobj.write(fname + '\000')
 
62
        b''  # self.fileobj.write(fname + '\000')
65
63
        ]
66
64
    # using a compressobj avoids a small header and trailer that the compress()
67
65
    # utility function adds.
77
75
    result.append(compress.flush())
78
76
    # size may exceed 2GB, or even 4GB
79
77
    result.append(struct.pack("<LL", LOWU32(crc), LOWU32(total_len)))
80
 
    return b''.join(result)
 
78
    return result