
                         v    S r SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
   " S S\5      rS
S jrSS	 jrg)z#Generates tarballs for Git trees.

    N)SEEK_END)BytesIO)closingc                   (    \ rS rSrSrS rSS jrSrg)ChunkedBytesIO#   a%  Turn a list of bytestrings into a file-like object.

This is similar to creating a `BytesIO` from a concatenation of the
bytestring list, but saves memory by NOT creating one giant bytestring
first::

    BytesIO(b''.join(list_of_bytestrings)) =~= ChunkedBytesIO(
        list_of_bytestrings)
c                     Xl         SU l        g )N)r   r   contentspos)selfr   s     "lib/third_party/dulwich/archive.py__init__ChunkedBytesIO.__init__.   s         Nc                    US:  a  [        S5      n/ nU R                  u  p4U[        U R                  5      :  a  U[        U R                  U   5      U-
  :  a0  UR	                  U R                  U   XDU-    5        XA-  nX44U l        OiUR	                  U R                  U   US  5        U[        U R                  U   5      U-
  -  nUS-  nSnX44U l        U[        U R                  5      :  a  M  SR                  U5      $ )Nr   inf   r   )floatr   lenr   appendjoin)r   maxbytesbufchunkcursors        r   readChunkedBytesIO.read2   s    a<U|Hc$--((#dmmE23f<<

4==/(9JKL"!?

4==/89Ce 45>>
!? c$--(( xx}r   r
   )N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r   #   s    r   r   c              #     #    [        5       n[        [        R                  " SSU-  U5      5       nUS:X  az  UR	                  S5        UR                  S5      S:X  d   S5       eUR	                  S5        UR                  [        R                  " S	U5      5        UR	                  S[        5        [        XU5       H  u  px XR                     n	[        U	R                  5      n
[        R                  " 5       nUR!                  S
5      Ul        U	R%                  5       Ul        UR(                  Ul        X+l        UR-                  X5        UR/                  5       v   UR1                  S5        UR	                  S5        M     SSS5        UR/                  5       v   g! [         a     M  f = f! , (       d  f       N2= f7f)a  Generate a tar stream for the contents of a Git tree.

Returns a generator that lazily assembles a .tar.gz archive, yielding it in
pieces (bytestrings). To obtain the complete .tar.gz binary file, simply
concatenate these chunks.

Args:
  store: Object store to retrieve objects from
  tree: Tree object for the tree root
  mtime: UNIX timestamp that is assigned as the modification time for
    all files, and the gzip header modification time if format='gz'
  format: Optional compression format for tarball
Returns:
  Bytestrings
Nzw:%sgzr      s   zInvalid gzip header   z<Lascii)r   r   tarfileopenseekr   writestructpackr   
_walk_treeshaKeyErrorr   chunkedTarInfodecodename
raw_lengthsizemodemtimeaddfilegetvaluetruncate)storetreer;   prefixformatr   tarentry_abspathentryblobdatainfos               r   
tar_streamrI   H   s[      )C	dFVOS9	:cT> HHQK88A;+-D/DD-HHQKIIfkk$./HHQ!$.uF$C MYY'
 "$,,/D??$D%,,W5DI)DI

DIJKK#,,. LLOHHQK' %D 
;B ,,.#   ! 
;	:sB   /GBF3F"B5F3G"
F0,F3/F00F33
G=Gc              #     #    UR                  5        Hs  n[        R                  " X#R                  5      n[        R
                  " UR                  5      (       a&  [        X UR                     U5       H  nUv   M	     Mn  XC4v   Mu     g7f)z^Recursively walk a dulwich Tree, yielding tuples of
(absolute path, TreeEntry) along the way.
N)		iteritems	posixpathr   pathstatS_ISDIRr:   r1   r2   )r?   r@   rootrE   rD   _s         r   r1   r1   }   sh      !!tZZ8<<

##UYY'7G H !(( "s   B	B)r    )r   )r#   rL   rN   r+   r/   osr   ior   
contextlibr   objectr   rI   r1   r%   r   r   <module>rW      s9   ,       "V "J2j
)r   