HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/dulwich/__pycache__/archive.cpython-39.pyc
a

�~�_��@spdZddlZddlZddlZddlZddlmZddlmZddl	m
Z
Gdd�de�Zdd
d�Z
ddd
�ZdS)z#Generates tarballs for Git trees.

�N)�SEEK_END)�BytesIO)�closingc@s"eZdZdZdd�Zddd�ZdS)�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)
    cCs||_d|_dS)N)rr)�contents�pos)�selfr�r	�1/usr/lib/python3/dist-packages/dulwich/archive.py�__init__-szChunkedBytesIO.__init__NcCs�|dkrtd�}g}|j\}}|t|j�kr�|t|j|�|krt|�|j||||��||7}||f|_q�q|�|j||d��|t|j|�|8}|d7}d}||f|_qd�|�S)Nr�inf��)�floatr�lenr�append�join)rZmaxbytes�buf�chunkZcursorr	r	r
�read1s 

zChunkedBytesIO.read)N)�__name__�
__module__�__qualname__�__doc__rrr	r	r	r
r#s	rr�c
cs8t�}tt�dd||����}|dkrn|�d�|�d�dksFJd��|�d�|�t�d	|��|�dt	�t
|||�D]�\}}z||j}	Wnty�YqzYn0t
|	j�}
t��}|�d
�|_|	��|_|j|_||_|�||
�|��V|�d�|�d�qzWd�n1�s 0Y|��VdS)aEGenerate 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
    Nzw:%sZgzr�s�zInvalid gzip header�z<L�ascii)rr�tarfile�open�seekr�write�structZpackr�
_walk_tree�sha�KeyErrorrZchunkedZTarInfo�decode�nameZ
raw_length�size�mode�mtimeZaddfile�getvalue�truncate)�store�treer*�prefix�formatrZtar�
entry_abspath�entryZblob�data�infor	r	r
�
tar_streamGs0






,r5ccsV|��D]H}t�||j�}t�|j�rFt|||j|�D]
}|Vq8q||fVqdS)zfRecursively walk a dulwich Tree, yielding tuples of
    (absolute path, TreeEntry) along the way.
    N)	Z	iteritems�	posixpathr�path�stat�S_ISDIRr)r#r$)r-r.�rootr2r1�_r	r	r
r#|s
r#)rr)r)rr6r8rr"�osr�ior�
contextlibr�objectrr5r#r	r	r	r
�<module>s$
5