/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/chunk_writer.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""ChunkWriter: write compressed data out with a fixed upper bound."""
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
20
import zlib
23
21
from zlib import Z_FINISH, Z_SYNC_FLUSH
24
22
 
101
99
        :param chunk_size: The total byte count to emit at the end of the
102
100
            chunk.
103
101
        :param reserved: How many bytes to allow for reserved data. reserved
104
 
            data space can only be written to via the write(..., reserved=True).
 
102
            data space can only be written to via the write(...,
 
103
            reserved=True).
105
104
        """
106
105
        self.chunk_size = chunk_size
107
106
        self.compressor = zlib.compressobj()
133
132
              could not fit.
134
133
            * num_nulls_needed: How many nulls are padded at the end
135
134
        """
136
 
        self.bytes_in = None # Free the data cached so far, we don't need it
 
135
        self.bytes_in = None  # Free the data cached so far, we don't need it
137
136
        out = self.compressor.flush(Z_FINISH)
138
137
        self.bytes_list.append(out)
139
138
        self.bytes_out_len += len(out)
144
143
                                 % (self.bytes_out_len, self.chunk_size))
145
144
        nulls_needed = self.chunk_size - self.bytes_out_len
146
145
        if nulls_needed:
147
 
            self.bytes_list.append("\x00" * nulls_needed)
 
146
            self.bytes_list.append(b"\x00" * nulls_needed)
148
147
        return self.bytes_list, self.unused_bytes, nulls_needed
149
148
 
150
149
    def set_optimize(self, for_size=True):
275
274
                    self.bytes_list = bytes_out
276
275
                    self.bytes_out_len = this_len
277
276
        return False
278