-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/chunk_writer.pyc

σ
ξ:οNc@@sRdZddlmZddlZddlmZmZdefd„ƒYZdS(s@ChunkWriter: write compressed data out with a fixed upper bound.i(tabsolute_importN(tZ_FINISHtZ_SYNC_FLUSHtChunkWritercB@sVeZdZd	Zd
Zded„Zd„Zed„Z	dd„Zed„ZRS(syChunkWriter allows writing of compressed data with a fixed size.

    If less data is supplied than fills a chunk, the chunk is padded with
    NULL bytes. If more data is supplied, then the writer packs as much
    in as it can, but never splits any item it was given.

    The algorithm for packing is open to improvement! Current it is:
     - write the bytes given
     - if the total seen bytes so far exceeds the chunk size, flush.

    :cvar _max_repack: To fit the maximum number of entries into a node, we
        will sometimes start over and compress the whole list to get tighter
        packing. We get diminishing returns after a while, so this limits the
        number of times we will try.
        The default is to try to avoid recompressing entirely, but setting this
        to something like 20 will give maximum compression.

    :cvar _max_zsync: Another tunable nob. If _max_repack is set to 0, then you
        can limit the number of times we will try to pack more data into a
        node. This allows us to do a single compression pass, rather than
        trying until we overflow, and then recompressing again.
    iiicC@st||_tjƒ|_g|_g|_d|_d|_d|_d|_	d|_||_|j
d|ƒdS(s5Create a ChunkWriter to write chunk_size chunks.

        :param chunk_size: The total byte count to emit at the end of the
            chunk.
        :param reserved: How many bytes to allow for reserved data. reserved
            data space can only be written to via the write(..., reserved=True).
        itfor_sizeN(t
chunk_sizetzlibtcompressobjt
compressortbytes_int
bytes_listt
bytes_out_lentunflushed_in_bytest
num_repackt	num_zsynctNonetunused_bytest
reserved_sizetset_optimize(tselfRtreservedtoptimize_for_size((s7/usr/lib/python2.7/dist-packages/bzrlib/chunk_writer.pyt__init__bs									cC@s±d|_|jjtƒ}|jj|ƒ|jt|ƒ7_|j|j	krqt
d|j|j	fƒ‚n|j	|j}|rž|jjd|ƒn|j|j|fS(sŠFinish the chunk.

        This returns the final compressed chunk, and either None, or the
        bytes that did not fit in the chunk.

        :return: (compressed_bytes, unused_bytes, num_nulls_needed)

            * compressed_bytes: a list of bytes that were output from the
              compressor. If the compressed length was not exactly chunk_size,
              the final string will be a string of all null bytes to pad this
              to chunk_size
            * unused_bytes: None, or the last bytes that were added, which we
              could not fit.
            * num_nulls_needed: How many nulls are padded at the end
        s:Somehow we ended up with too much compressed data, %d > %dtN(RR	RtflushRR
tappendRtlenRtAssertionErrorR(Rtouttnulls_needed((s7/usr/lib/python2.7/dist-packages/bzrlib/chunk_writer.pytfinishxs	cC@s1|rtj}n	tj}|\|_|_dS(sΐChange how we optimize our writes.

        :param for_size: If True, optimize for minimum space usage, otherwise
            optimize for fastest writing speed.
        :return: None
        N(Rt_repack_opts_for_sizet_repack_opts_for_speedt_max_repackt
_max_zsync(RRtopts((s7/usr/lib/python2.7/dist-packages/bzrlib/chunk_writer.pyR–s	c	C@s«tjƒ}g}|j}|j}x0|jD]%}||ƒ}|r.||ƒq.q.W|r‰||ƒ}||jtƒ7}||ƒnttt	|ƒƒ}|||fS(sΧRecompress the current bytes_in, and optionally more.

        :param extra_bytes: Optional, if supplied we will add it with
            Z_SYNC_FLUSH
        :return: (bytes_out, bytes_out_len, alt_compressed)

            * bytes_out: is the compressed bytes returned from the compressor
            * bytes_out_len: the length of the compressed output
            * compressor: An object with everything packed in so far, and
              Z_SYNC_FLUSH called.
        (
RRRtcompressR	RRtsumtmapR(	Rtextra_bytesRt	bytes_outRR$taccepted_bytesRR((s7/usr/lib/python2.7/dist-packages/bzrlib/chunk_writer.pyt_recompress_all_bytes_in£s		
cC@s¦|j|jkr&|r&||_tS|r8|j}n|j|j}|j}|jt|ƒ}||j	d}||krζ|j
|ƒ}|rΎ|jj|ƒ|j	t|ƒ7_	n|j
j|ƒ|jt|ƒ7_nΌ|jd7_|jdkr2|j|jkr2|jd7_||_tS|j
|ƒ}||jtƒ7}d|_|r‹|jj|ƒ|j	t|ƒ7_	n|jdkr£d}nd}|j	||krΟ|j
j|ƒnΣ|jd7_|j|ƒ\}	}
}|j|jkr|jd7_n|
d|krw|jƒ\}	}
}||_|jd|_|	|_|
|_	||_tS||_|j
j|ƒ|	|_|
|_	tS(s4Write some bytes to the chunk.

        If the bytes fit, False is returned. Otherwise True is returned
        and the bytes have not been added to the chunk.

        :param bytes: The bytes to include
        :param reserved: If True, we can use the space reserved in the
            constructor.
        i
iiid(R
R!RtTrueRRRRRRR$R
RR	RR"RRR*tFalse(RtbytesRtcapacitytcomptnext_unflushedtremaining_capacityRt
safety_marginR(tthis_lenR((s7/usr/lib/python2.7/dist-packages/bzrlib/chunk_writer.pytwriteΎsb
			!										(ii(iiN(
t__name__t
__module__t__doc__R RR,RRR+RRR*R4(((s7/usr/lib/python2.7/dist-packages/bzrlib/chunk_writer.pyRs/	
(R7t
__future__RRRRtobjectR(((s7/usr/lib/python2.7/dist-packages/bzrlib/chunk_writer.pyt<module>s

Copyright © 2017 || Recoded By Mr.Bumblebee