-=[ Mr. Bumblebee ]=-
_Indonesia_

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

ó
î:ïNc@@sdZddlmZddlmZddlZddlmZdZej	dƒZ
d„Zd	„Zd
e
fd„ƒYZde
fd
„ƒYZde
fd„ƒYZd„Zde
fd„ƒYZdefd„ƒYZdefd„ƒYZde
fd„ƒYZd„ZdS(stContainer format for Bazaar data.

"Containers" and "records" are described in
doc/developers/container-format.txt.
i(tabsolute_import(tStringION(terrorss)Bazaar pack format 1 (introduced in 0.18)s[	

 ]cC@s2tj|ƒdk	r.tjd|fƒ‚ndS(sÜDo some basic checking of 'name'.

    At the moment, this just checks that there are no whitespace characters in a
    name.

    :raises InvalidRecordError: if name is not valid.
    :seealso: _check_name_encoding
    s%r is not a valid name.N(t_whitespace_retsearchtNoneRtInvalidRecordError(tname((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyt_check_name%s	cC@s@y|jdƒWn(tk
r;}tjt|ƒƒ‚nXdS(sßCheck that 'name' is valid UTF-8.

    This is separate from _check_name because UTF-8 decoding is relatively
    expensive, and we usually want to avoid it.

    :raises InvalidRecordError: if name is not valid UTF-8.
    sutf-8N(tdecodetUnicodeDecodeErrorRRtstr(Rte((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyt_check_name_encoding2stContainerSerialisercB@s2eZdZd„Zd„Zd„Zd„ZRS(sÍA helper class for serialising containers.

    It simply returns bytes from method calls to 'begin', 'end' and
    'bytes_record'.  You may find ContainerWriter to be a more convenient
    interface.
    cC@stdS(s&Return the bytes to begin a container.s
(t
FORMAT_ONE(tself((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytbeginHscC@sdS(s'Return the bytes to finish a container.tE((R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytendLscC@s€dg}|jt|ƒdƒxC|D];}x|D]}t|ƒq4W|jdj|ƒdƒq'W|jdƒdj|ƒS(s%Return the header for a Bytes record.tBs
tt(tappendRRtjoin(Rtlengthtnamest
byte_sectionst
name_tupleR((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytbytes_headerPs	


cC@s|jt|ƒ|ƒ|S(sÆReturn the bytes for a Bytes record with the given name and
        contents.

        If the content may be large, construct the header separately and then
        stream out the contents.
        (Rtlen(RtbytesR((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytbytes_recordas(t__name__t
__module__t__doc__RRRR (((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR@s
			tContainerWritercB@sAeZdZdZd„Zd„Zd„Zd„Zd„ZRS(súA class for writing containers to a file.

    :attribute records_written: The number of user records added to the
        container. This does not count the prelude or suffix of the container
        introduced by the begin() and end() methods.
    i †cC@s+||_d|_d|_tƒ|_dS(s‘Constructor.

        :param write_func: a callable that will be called when this
            ContainerWriter needs to write some bytes.
        iN(t_write_functcurrent_offsettrecords_writtenRt_serialiser(Rt
write_func((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyt__init__ws			cC@s|j|jjƒƒdS(sBegin writing a container.N(R)R(R(R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR‚scC@s&|j|ƒ|jt|ƒ7_dS(N(R%R&R(RR((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR)†s
cC@s|j|jjƒƒdS(sFinish writing a container.N(R)R(R(R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRŠscC@s|j}t|ƒ}||jkrG|j|jj||ƒ|ƒn)|j|jj||ƒƒ|j|ƒ|jd7_||j|fS(s²Add a Bytes record with the given names.

        :param bytes: The bytes to insert.
        :param names: The names to give the inserted bytes. Each name is
            a tuple of bytestrings. The bytestrings may not contain
            whitespace.
        :return: An offset, length tuple. The offset is the offset
            of the record within the container, and the length is the
            length of data that will need to be read to reconstitute the
            record. These offset and length can only be used with the pack
            interface - they might be offset by headers or other such details
            and thus are only suitable for use by a ContainerReader.
        i(R&Rt_JOIN_WRITES_THRESHOLDR)R(RR'(RRRR&R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytadd_bytes_recordŽs	
(	R!R"R#R+R*RR)RR,(((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR$ks				t	ReadVFilecB@s2eZdZd„Zd„Zd„Zd„ZRS(s¢Adapt a readv result iterator to a file like protocol.
    
    The readv result must support the iterator protocol returning (offset,
    data_bytes) pairs.
    cC@s"t|ƒ}||_d|_dS(sŸConstruct a new ReadVFile wrapper.

        :seealso: make_readv_reader

        :param readv_result: the most recent readv result - list or generator
        N(titertreadv_resultRt_string(RR/((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR*³s		cC@sa|jdks'|jjƒ|jkr]|jjƒ\}}t|ƒ|_t|ƒ|_ndS(N(R0Rttellt_string_lengthR/tnextRR(Rtoffsettdata((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyt_nextÀs
cC@s[|jƒ|jj|ƒ}t|ƒ|krWtjd|t|ƒ|d fƒ‚n|S(Ns5wanted %d bytes but next hunk only contains %d: %r...i(R6R0treadRRtBzrError(RRtresult((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR7Çs
	 cC@s^|jƒ|jjƒ}|jjƒ|jkrZ|ddkrZtjd|fƒ‚n|S(s1Note that readline will not cross readv segments.iÿÿÿÿs
s(short readline in the readvfile hunk: %r(R6R0treadlineR1R2RR8(RR9((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR:Ðs
(	(R!R"R#R*R6R7R:(((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR-©s
	
			cC@sHdttƒdfg}|j|ƒtt|j||ƒƒƒ}|S(s9Create a ContainerReader that will read selected records only.

    :param transport: The transport the pack file is located on.
    :param filename: The filename of the pack file.
    :param requested_records: The record offset, length tuples as returned
        by add_bytes_record for the desired records.
    ii(RRtextendtContainerReaderR-treadv(t	transporttfilenametrequested_recordstreadv_blocksR9((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytmake_readv_readerÚs

t
BaseReadercB@s&eZd„Zdd„Zd„ZRS(cC@s
||_dS(suConstructor.

        :param source_file: a file-like object with `read` and `readline`
            methods.
        N(t_source(Rtsource_file((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR*ëscC@s|jj|ƒS(N(RDR7(RR((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytreader_funcóscC@s:|jjƒ}|jdƒs-tjƒ‚n|jdƒS(Ns
(RDR:tendswithRtUnexpectedEndOfContainerErrortrstrip(Rtline((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyt
_read_lineösN(R!R"R*RRFRK(((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRCés	R<cB@sDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s.A class for reading Bazaar's container format.cC@s|jƒ|jƒS(sƒIterate over the container, yielding each record as it is read.

        Each yielded record will be a 2-tuple of (names, callable), where names
        is a ``list`` and bytes is a function that takes one argument,
        ``max_length``.

        You **must not** call the callable after advancing the iterator to the
        next record.  That is, this code is invalid::

            record_iter = container.iter_records()
            names1, callable1 = record_iter.next()
            names2, callable2 = record_iter.next()
            bytes1 = callable1(None)

        As it will give incorrect results and invalidate the state of the
        ContainerReader.

        :raises ContainerError: if any sort of container corruption is
            detected, e.g. UnknownContainerFormatError is the format of the
            container is unrecognised.
        :seealso: ContainerReader.read
        (t_read_formatt
_iter_records(R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytiter_recordss
cC@s|jƒ|jƒS(sûIterate over the container, yielding each record as it is read.

        Each yielded record will be an object with ``read`` and ``validate``
        methods.  Like with iter_records, it is not safe to use a record object
        after advancing the iterator to yield next record.

        :raises ContainerError: if any sort of container corruption is
            detected, e.g. UnknownContainerFormatError is the format of the
            container is unrecognised.
        :seealso: iter_records
        (RLt_iter_record_objects(R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytiter_record_objectss
cc@s&x|jƒD]}|jƒVq
WdS(N(ROR7(Rtrecord((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRM)scc@s}xvtrx|jdƒ}|dkr;t|jƒ}|Vq|dkrKdS|dkrftjƒ‚qtj|ƒ‚qWdS(NiRRR(tTrueRFtBytesRecordReaderRDRRHtUnknownRecordTypeError(Rtrecord_kindtreader((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRO-s	cC@s.|jƒ}|tkr*tj|ƒ‚ndS(N(RKRRtUnknownContainerFormatError(Rtformat((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRL?scC@s¼tƒ}x|jƒD]q\}}|dƒxX|D]P}x|D]}t|ƒq@W||krvtj|dƒ‚n|j|ƒq3WqW|jdƒ}|dkr¸tj|ƒ‚ndS(sValidate this container and its records.

        Validating consumes the data stream just like iter_records and
        iter_record_objects, so you cannot call it after
        iter_records/iter_record_objects.

        :raises ContainerError: if something is invalid.
        iiRN(	tsetRNRR
RtDuplicateRecordNameErrortaddRFtContainerHasExcessDataError(Rt	all_namestrecord_namest
read_bytesRRtexcess_bytes((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytvalidateDs		


(	R!R"R#RNRPRMRORLRa(((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR<ýs					RScB@s#eZd„Zd„Zd„ZRS(cC@sÈ|jƒ}yt|ƒ}Wn'tk
rEtjd|fƒ‚nXg}xctr±|jƒ}|dkrqPnt|jdƒƒ}x|D]}t|ƒqW|j	|ƒqOW||_
||jfS(sâRead this record.

        You can either validate or read a record, you can't do both.

        :returns: A tuple of (names, callable).  The callable can be called
            repeatedly to obtain the bytes for the record, with a max_length
            argument.  If max_length is None, returns all the bytes.  Because
            records can be arbitrarily large, using None is not recommended
            unless you have reason to believe the content will fit in memory.
        s%r is not a valid length.RR(RKtintt
ValueErrorRRRRttupletsplitRRt_remaining_lengtht_content_reader(Rtlength_lineRRt	name_lineRR((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR7as"
	
	cC@sm|dkr|j}nt||jƒ}|j|8_|j|ƒ}t|ƒ|kritjƒ‚n|S(N(RRftminRFRRRH(Rt
max_lengthtlength_to_readR((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRg‚scC@sL|jƒ\}}x)|D]!}x|D]}t|ƒq&WqW|dƒdS(s—Validate this record.

        You can either validate or read, you can't do both.

        :raises ContainerError: if this record is invalid.
        N(R7R
R(RRR_RR((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRas


(R!R"R7RgRa(((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRS_s	!	tContainerPushParsercB@s}eZdZd„Zd„Zd„Zd
d„Zd„Zd„Z	d„Z
d„Zd	„Zd
„Z
d„Zd„ZRS(sÄA "push" parser for container format 1.

    It accepts bytes via the ``accept_bytes`` method, and parses them into
    records which can be retrieved via the ``read_pending_records`` method.
    cC@s5d|_|j|_g|_|jƒt|_dS(NR(t_buffert_state_expecting_format_linet_state_handlert_parsed_recordst_reset_current_recordtFalsetfinished(R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR*¢s
		
cC@sd|_g|_dS(N(Rt_current_record_lengtht_current_record_names(R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRr©s	cC@sx|j|7_d}t|jƒ}d}xG||ksH||jkrs|}|j}|jƒt|jƒ}q-WdS(N(RnRRRp(RRtlast_buffer_lengthtcur_buffer_lengthtlast_state_handler((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytaccept_bytes­s	
cC@s;|r!|j| }|j|4|S|j}g|_|SdS(N(Rq(Rtmaxtrecords((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytread_pending_records»s

		cC@sK|jjdƒ}|dkrC|j| }|j|d|_|SdSdS(s²Take a line out of the buffer, and return the line.

        If a newline byte is not found in the buffer, the buffer is
        unchanged and this returns None instead.
        s
iÿÿÿÿiN(RntfindR(Rtnewline_posRJ((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyt
_consume_lineÅs
cC@sI|jƒ}|dk	rE|tkr6tj|ƒ‚n|j|_ndS(N(R€RRRRWt_state_expecting_record_typeRp(RRJ((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRoÓs
cC@s‡t|jƒdkrƒ|jd}|jd|_|dkrM|j|_qƒ|dkrqt|_|j|_qƒtj|ƒ‚ndS(NiiRR(	RRnt_state_expecting_lengthRpRRRtt_state_expecting_nothingRRT(Rtrecord_type((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRÚs
	cC@sh|jƒ}|dk	rdyt|ƒ|_Wn'tk
rTtjd|fƒ‚nX|j|_ndS(Ns%r is not a valid length.(	R€RRbRuRcRRt_state_expecting_nameRp(RRJ((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR‚æs
cC@st|jƒ}|dkr'|j|_nI|rpt|jdƒƒ}x|D]}t|ƒqIW|jj|ƒndS(NRR(R€t_state_expecting_bodyRpRdReRRvR(Rtencoded_name_partst
name_partst	name_part((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR…ðs
cC@swt|jƒ|jkrs|j|j }|j|j|_|j|f}|jj|ƒ|jƒ|j|_ndS(N(	RRnRuRvRqRRrRRp(Rt
body_bytesRQ((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyR†ús
cC@sdS(N((R((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRƒscC@sTd}|j|jkrP|jt|jƒ}|dkrCd}nt||ƒS|S(Ni@i(RpR†RuRRnR{(Rthintt	remaining((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytread_size_hints	
N(R!R"R#R*RrRzRR}R€RoRR‚R…R†RƒR(((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyRm›s			
				
	
			cc@setƒ}xUtr`|j|jƒƒ}|j|ƒx|jƒD]}|VqAW|jrPqqWdS(N(RmRRR7RRzR}Rt(REtparserRRQ((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pytiter_records_from_files		
		(R#t
__future__Rt	cStringIORtretbzrlibRRtcompileRRR
tobjectRR$R-RBRCR<RSRmR(((s//usr/lib/python2.7/dist-packages/bzrlib/pack.pyt<module>s"	
	+>1	b<u

Copyright © 2017 || Recoded By Mr.Bumblebee