§
    |{Èc«  ã                   óx   — d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
  G d„ d¦  «        Zdd
„Zdd„ZdS )z#Generates tarballs for Git trees.

é    N)ÚSEEK_END)ÚBytesIO)Úclosingc                   ó    — e Zd ZdZd„ Zdd„ZdS )ÚChunkedBytesIOa=  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                 ó"   — || _         d| _        d S )N)r   r   )ÚcontentsÚpos)Úselfr	   s     ú1/usr/lib/python3/dist-packages/dulwich/archive.pyÚ__init__zChunkedBytesIO.__init__.   s   € Ø ˆŒØˆŒˆˆó    Nc                 ó4  — |dk     rt          d¦  «        }g }| j        \  }}|t          | j        ¦  «        k     rË|t          | j        |         ¦  «        |z
  k     r:|                     | j        |         |||z   …         ¦  «         ||z  }||f| _        np|                     | j        |         |d …         ¦  «         |t          | j        |         ¦  «        |z
  z  }|dz  }d}||f| _        |t          | j        ¦  «        k     °Ëd                     |¦  «        S )Nr   Úinfé   r   )Úfloatr
   Úlenr	   ÚappendÚjoin)r   ÚmaxbytesÚbufÚchunkÚcursors        r   ÚreadzChunkedBytesIO.read2   s  € Ø�aŠ<ˆ<Ý˜U‘|”|ˆHàˆØœ‰ˆˆvà•c˜$œ-Ñ(Ô(Ò(Ð(Ø�#˜dœm¨EÔ2Ñ3Ô3°fÑ<Ò<Ð<Ø—
’
˜4œ=¨Ô/°¸À(Ñ9JÐ0JÔKÑLÔLÐLØ˜(Ñ"�Ø! 6˜?�”Øà—
’
˜4œ=¨Ô/°°°Ô8Ñ9Ô9Ð9Ø�C ¤¨eÔ 4Ñ5Ô5¸Ñ>Ñ>�Ø˜‘
�Ø�Ø! 6˜?�”ð •c˜$œ-Ñ(Ô(Ò(Ð(ð �xŠx˜‰}Œ}Ðr   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r   #   sA   € € € € € ðð ðð ð ðð ð ð ð ð r   r   r   Ú c              #   óð  K  — t          ¦   «         }t          t          j        dd|z  |¦  «        ¦  «        5 }|dk    r�|                     d¦  «         |                     d¦  «        dk    s
J d¦   «         ‚|                     d¦  «         |                     t          j        d	|¦  «        ¦  «         |                     dt          ¦  «         t          | ||¦  «        D ]è\  }}	 | |j                 }	n# t          $ r Y Œ w xY wt          |	j        ¦  «        }
t          j        ¦   «         }|                     d
d¦  «        |_        |	                     ¦   «         |_        |j        |_        ||_        |                     ||
¦  «         |                     ¦   «         V — |                     d¦  «         |                     d¦  «         Œé	 ddd¦  «         n# 1 swxY w Y   |                     ¦   «         V — dS )aE  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<Lzutf-8Úsurrogateescape)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Útreer6   ÚprefixÚformatr   ÚtarÚentry_abspathÚentryÚblobÚdataÚinfos               r   Ú
tar_streamrD   H   s  è è € õ  ‰)Œ)€CÝ	•”˜d F¨V¡O°SÑ9Ô9Ñ	:Ô	:ð  ¸cØ�TŠ>ˆ>ð �HŠH�Q‰KŒKˆKØ—8’8˜A‘;”; +Ò-Ð-Ð-Ð/DÑ-Ô-Ð-Ø�HŠH�Q‰KŒKˆKØ�IŠI•f”k $¨Ñ.Ô.Ñ/Ô/Ð/Ø�HŠH�Q�Ñ!Ô!Ð!å$.¨u°d¸FÑ$CÔ$Cð 	ð 	Ñ ˆM˜5ðØ˜UœYÔ'��øÝð ð ð ð �ðøøøõ " $¤,Ñ/Ô/ˆDå”?Ñ$Ô$ˆDà%×,Ò,¨WÐ6GÑHÔHˆDŒIØŸšÑ)Ô)ˆDŒIØœ
ˆDŒIØˆDŒJà�KŠK˜˜dÑ#Ô#Ð#Ø—,’,‘.”.Ð Ð Ð Ø�LŠL˜‰OŒOˆOØ�HŠH�Q‰KŒKˆKˆKð'	ð ð  ð  ñ  ô  ð  ð  ð  ð  ð  ð  øøøð  ð  ð  ð  ðB �,Š,‰.Œ.ÐÐÐÐÐs7   ·B-GÃ%C3Ã2GÃ3
D Ã=GÃ?D Ä CGÇGÇGc              #   óð   K  — |                      ¦   «         D ]^}t          j        ||j        ¦  «        }t	          j        |j        ¦  «        r#t          | | |j                 |¦  «        E d{V —† ŒX||fV — Œ_dS )zfRecursively walk a dulwich Tree, yielding tuples of
    (absolute path, TreeEntry) along the way.
    N)	Ú	iteritemsÚ	posixpathr   ÚpathÚstatÚS_ISDIRr5   r,   r-   )r:   r;   Úrootr@   r?   s        r   r,   r,   }   s”   è è € ð —’Ñ!Ô!ð )ð )ˆÝ!œ t¨U¬ZÑ8Ô8ˆÝŒ<˜œ
Ñ#Ô#ð 	)Ý! %¨¨u¬yÔ)9¸=ÑIÔIÐIÐIÐIÐIÐIÐIÐIÐIà  %Ð(Ð(Ð(Ð(Ð(ð)ð )r   )r   r    )r   )r   rG   rI   r&   r*   Úosr   Úior   Ú
contextlibr   r   rD   r,   r   r   r   ú<module>rO      sÊ   ðð,ð ð Ð Ð Ð Ø €€€Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ð"ð "ð "ð "ð "ñ "ô "ð "ðJ2ð 2ð 2ð 2ðj	)ð 	)ð 	)ð 	)ð 	)ð 	)r   