
    g                         d Z g dZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZmZmZmZmZ dd	lmZ erdd
lmZ eZdZdZdZdZdZ G d d      Z G d de      Z G d de      Z G d de      Z y)z#Additional types used by the index.)
BlobFilterBaseIndexEntry
IndexEntry	StageType    )b2a_hex)Path)Blob   )packunpack)
NamedTupleSequenceTYPE_CHECKINGTupleUnioncast)PathLike)Repoi  i 0  i @  i      c                   D    e Zd ZdZdZdee   ddfdZdee	e
f   defdZy)	r   zPredicate to be used by
    :meth:`IndexFile.iter_blobs <git.index.base.IndexFile.iter_blobs>` allowing to
    filter only return blobs which match the given list of directories or files.

    The given paths are given relative to the repository.
    pathsr   returnNc                     || _         y)z
        :param paths:
            Tuple or list of paths which are either pointing to directories or to files
            relative to the current repository.
        Nr   )selfr   s     B/var/www/openai/venv/lib/python3.12/site-packages/git/index/typ.py__init__zBlobFilter.__init__0   s     
    
stage_blobc                 T   |d   j                   }t        |t              r|n
t        |      }| j                  D ]m  }t        |t              r|n
t        |      }|j                  }|j                  }t        |      t        |      kD  rPt        d t        ||      D              sm y y)Nr
   c              3   ,   K   | ]  \  }}||k(    y w)N ).0ijs      r   	<genexpr>z&BlobFilter.__call__.<locals>.<genexpr>C   s     D&Cda16&Cs   TF)path
isinstancer   r   partslenallzip)r   r   blob_pathlike	blob_pathpathliker'   filter_parts
blob_partss           r   __call__zBlobFilter.__call__8   s    ",Q-"4"4+5mT+J-PTUbPc	

H%/$%?T(^D  ::L"J< 3z?2Dc,
&CDD # r   )__name__
__module____qualname____doc__	__slots__r   r   r   r   r   r	   boolr2   r"   r   r   r   r   &   sB     Ihx0 T 5D#9 d r   r   c                       e Zd ZU dZeed<   eed<   eed<   eed<    eddd      Z	eed<    eddd      Z
eed	<   dZeed
<   dZeed<   dZeed<   dZeed<   dZeed<   y)BaseIndexEntryHelperzTyped named tuple to provide named attribute access for :class:`BaseIndexEntry`.

    This is needed to allow overriding ``__new__`` in child class to preserve backwards
    compatibility.
    modebinshaflagsr'   >LLr   ctime_bytesmtime_bytesdevinodeuidgidsizeN)r3   r4   r5   r6   int__annotations__bytesr   r   r?   r@   rA   rB   rC   rD   rE   r"   r   r   r:   r:   H   sp     IMJ
NeQ*K*eQ*K*CLE3NCLCLD#Mr   r:   c                        e Zd ZdZdeeeeeef   eeeeeeeeeeeef   f   dd f fdZ	de
fdZde
fdZede
fd       Zedefd       Zedd	ed
edd fd       ZdddefdZ xZS )r   a  Small brother of an index entry which can be created to describe changes
    done to the index in which case plenty of additional information is not required.

    As the first 4 data members match exactly to the :class:`IndexEntry` type, methods
    expecting a :class:`BaseIndexEntry` can also handle full :class:`IndexEntry`\s even
    if they use numeric indices for performance reasons.
    	inp_tupler   c                 $    t        |   | g| S )z\Override ``__new__`` to allow construction from a tuple for backwards
        compatibility.)super__new__)clsrJ   	__class__s     r   rM   zBaseIndexEntry.__new__e   s     ws/Y//r   c                 d    d| j                   | j                  | j                  | j                  fz  S )Nz%o %s %i	%sr;   hexshastager'   r   s    r   __str__zBaseIndexEntry.__str__p   s&    DKKTYY OOOr   c                 d    d| j                   | j                  | j                  | j                  fz  S )Nz(%o, %s, %i, %s)rQ   rT   s    r   __repr__zBaseIndexEntry.__repr__s   s&    !TYYTZZ$SSSr   c                 J    t        | j                        j                  d      S )zhex version of our shaascii)r   r<   decoderT   s    r   rR   zBaseIndexEntry.hexshav   s     t{{#**733r   c                 6    | j                   t        z  t        z	  S )a|  Stage of the entry, either:

            * 0 = default stage
            * 1 = stage before a merge or common ancestor entry in case of a 3 way merge
            * 2 = stage of entries from the 'left' side of the merge
            * 3 = stage of entries from the 'right' side of the merge

        :note:
            For more information, see :manpage:`git-read-tree(1)`.
        )r=   CE_STAGEMASKCE_STAGESHIFTrT   s    r   rS   zBaseIndexEntry.stage{   s     

\)m;;r   blobrS   c                 d     | |j                   |j                  |t        z  |j                  f      S )z9:return: Fully equipped BaseIndexEntry at the given stage)r;   r<   r]   r'   )rN   r^   rS   s      r   	from_blobzBaseIndexEntry.from_blob   s)     DIIt{{E],BDIINOOr   repor   c                 Z    t        || j                  | j                  | j                        S )z7:return: Blob using the information of this index entry)r	   r<   r;   r'   )r   ra   s     r   to_blobzBaseIndexEntry.to_blob   s    D$++tyy$))<<r   r   )r3   r4   r5   r6   r   r   rF   rH   r   rM   strrU   rW   propertyrR   rS   classmethodr	   r`   rc   __classcell__)rO   s   @r   r   r   \   s    	0#uc8+,#uc8UE3S#sRSU
	0 
	0P PT# T 4 4 4 <s < < PT P# P6F P P=F =t =r   r   c                       e Zd ZdZedeeef   fd       Zedeeef   fd       Ze	d
d       Z
e	ddededd fd       Zy	)r   a-  Allows convenient access to index entry data as defined in
    :class:`BaseIndexEntry` without completely unpacking it.

    Attributes usually accessed often are cached in the tuple whereas others are
    unpacked on demand.

    See the properties for a mapping between names and tuple indices.
    r   c                 d    t        t        t        t        f   t        d| j                              S )z
        :return:
            Tuple(int_time_seconds_since_epoch, int_nano_seconds) of the
            file's creation time
        r>   )r   r   rF   r   r?   rT   s    r   ctimezIndexEntry.ctime   s&     E#s(OVE43C3C%DEEr   c                 d    t        t        t        t        f   t        d| j                              S )z:See :attr:`ctime` property, but returns modification time.r>   )r   r   rF   r   r@   rT   s    r   mtimezIndexEntry.mtime   s&     E#s(OVE43C3C%DEEr   c                     t        ddd      }t        |j                  |j                  |j                  |j
                  ||dddddf      S )z
        :return:
            Minimal entry as created from the given :class:`BaseIndexEntry` instance.
            Missing values will be set to null-like values.

        :param base:
            Instance of type :class:`BaseIndexEntry`.
        r>   r   )r   r   r;   r<   r=   r'   )rN   basetimes      r   	from_basezIndexEntry.from_base   sJ     E1a 499dkk4::tyy$PTVWYZ\]_`bcdeer   r^   rS   c                     t        ddd      }t        |j                  |j                  |t        z  |j
                  ||dddd|j                  f      S )z7:return: Minimal entry resembling the given blob objectr>   r   )r   r   r;   r<   r]   r'   rE   )rN   r^   rS   rp   s       r   r`   zIndexEntry.from_blob   sZ     E1a 		&				
 	
r   N)ro   r   r   r   rd   )r3   r4   r5   r6   rf   r   rF   rk   rm   rg   rq   r	   r`   r"   r   r   r   r      s     FuS#X F F FuS#X F F 
f 
f 
T 
# 
l 
 
r   r   N)!r6   __all__binasciir   pathlibr   git.objectsr	   utilr   r   typingr   r   r   r   r   r   	git.typesr   git.repor   rF   r   CE_NAMEMASKr\   CE_EXTENDEDCE_VALIDr]   r   r:   r   r   r"   r   r   <module>r~      s~    *
E     K J 	
 
 D: (4=) 4=n7
 7
r   