
    .PhW                     B   d Z ddlmZ ddlmZmZ dZ G d de          Z G d de          Z	 G d	 d
e	          Z
 G d de          Z G d de          Z G d de	          Z G d de
          Z G d de          Z G d de          Z G d de          ZdS )zPModule with basic data structures - they are designed to be lightweight and fast    
bin_to_hex)type_id_to_type_maptype_to_type_id_map)	OInfo	OPackInfoODeltaPackInfoOStreamOPackStreamODeltaPackStreamIStreamInvalidOInfoInvalidOStreamc                       e Zd ZdZ e            Zd Zd Zed             Z	ed             Z
ed             Zed             Zed             Zd	S )
r   a  Carries information about an object in an ODB, providing information
    about the binary sha of the object, the type_string as well as the uncompressed size
    in bytes.

    It can be accessed using tuple notation and using attribute access notation::

        assert dbi[0] == dbi.binsha
        assert dbi[1] == dbi.type
        assert dbi[2] == dbi.size

    The type is designed to be as lightweight as possible.c                 >    t                               | |||f          S Ntuple__new__)clsshatypesizes       J/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/gitdb/base.pyr   zOInfo.__new__#   s    }}S3d"3444    c                 :    t                               |            d S r   r   __init__selfargss     r   r   zOInfo.__init__&       tr   c                     | d         S )z$:return: our sha as binary, 20 bytesr    r    s    r   binshazOInfo.binsha*        Awr   c                 ,    t          | d                   S z':return: our sha, hex encoded, 40 bytesr   r   r%   s    r   hexshazOInfo.hexsha/        $q'"""r   c                     | d         S N   r$   r%   s    r   r   z
OInfo.type4       Awr   c                 (    t           | d                  S r-   )r   r%   s    r   type_idzOInfo.type_id8       "47++r   c                     | d         S N   r$   r%   s    r   r   z
OInfo.size<   r/   r   N)__name__
__module____qualname____doc__r   	__slots__r   r   propertyr&   r*   r   r1   r   r$   r   r   r   r      s        
> 
> I5 5 5     X # # X#   X , , X,   X  r   r   c                       e Zd ZdZ e            Zd Zd Zed             Z	ed             Z
ed             Zed             ZdS )	r   a`  As OInfo, but provides a type_id property to retrieve the numerical type id, and
    does not include a sha.

    Additionally, the pack_offset is the absolute offset into the packfile at which
    all object information is located. The data_offset property points to the absolute
    location in the pack at which that actual data stream can be found.c                 >    t                               | |||f          S r   r   )r   
packoffsetr   r   s       r   r   zOPackInfo.__new__L   s    }}S:tT":;;;r   c                 :    t                               |            d S r   r   r   s     r   r   zOPackInfo.__init__O   r"   r   c                     | d         S Nr   r$   r%   s    r   pack_offsetzOPackInfo.pack_offsetT   r/   r   c                 (    t           | d                  S r-   )r   r%   s    r   r   zOPackInfo.typeX   r2   r   c                     | d         S r-   r$   r%   s    r   r1   zOPackInfo.type_id\   r/   r   c                     | d         S r4   r$   r%   s    r   r   zOPackInfo.size`   r/   r   N)r6   r7   r8   r9   r   r:   r   r   r;   rB   r   r1   r   r$   r   r   r   r   B   s        K K I< < <  
   X , , X,   X   X  r   r   c                   B    e Zd ZdZ e            Zd Zed             ZdS )r	   zAdds delta specific information,
    Either the 20 byte sha which points to some object in the database,
    or the negative offset from the pack_offset, so that pack_offset - delta_info yields
    the pack offset of the base objectc                 @    t                               | ||||f          S r   r   )r   r>   r   r   
delta_infos        r   r   zODeltaPackInfo.__new__o   s    }}S:tT:"FGGGr   c                     | d         S N   r$   r%   s    r   rH   zODeltaPackInfo.delta_infos   r/   r   N)	r6   r7   r8   r9   r   r:   r   r;   rH   r$   r   r   r	   r	   g   sX        * * IH H H   X  r   r	   c                   P    e Zd ZdZ e            Zd Zd ZddZe	d             Z
dS )	r
   zBase for object streams retrieved from the database, providing additional
    information about the stream.
    Generally, ODB streams are read-only as objects are immutablec                 @    t                               | ||||f          S z+Helps with the initialization of subclassesr   r   r   r   r   streamr!   kwargss          r   r   zOStream.__new__       }}S3dF";<<<r   c                 :    t                               |            d S r   r   )r    r!   rQ   s      r   r   zOStream.__init__   r"   r   c                 8    | d                              |          S rJ   readr    r   s     r   rW   zOStream.read       Aw||D!!!r   c                     | d         S rJ   r$   r%   s    r   rP   zOStream.stream   r/   r   NrT   )r6   r7   r8   r9   r   r:   r   r   rW   r;   rP   r$   r   r   r
   r
   y   sz        E E I= = =  
" " " "   X  r   r
   c                   .    e Zd ZdZd Zed             ZdS )ODeltaStreamz,Uses size info of its stream, delaying readsc                 @    t                               | ||||f          S rN   r   rO   s          r   r   zODeltaStream.__new__   rR   r   c                     | d         j         S rJ   )r   r%   s    r   r   zODeltaStream.size   s    Aw|r   N)r6   r7   r8   r9   r   r;   r   r$   r   r   r]   r]      sD        66= = =   X  r   r]   c                   J    e Zd ZdZ e            Zd ZddZed             Z	dS )r   z_Next to pack object information, a stream outputting an undeltified base object
    is providedc                 @    t                               | ||||f          S rN   r   )r   r>   r   r   rP   r!   s         r   r   zOPackStream.__new__   s    }}S:tT6"BCCCr   rT   c                 8    | d                              |          S rJ   rV   rX   s     r   rW   zOPackStream.read   rY   r   c                     | d         S rJ   r$   r%   s    r   rP   zOPackStream.stream   r/   r   Nr[   
r6   r7   r8   r9   r   r:   r   rW   r;   rP   r$   r   r   r   r      sj         ID D D
" " " "   X  r   r   c                   J    e Zd ZdZ e            Zd ZddZed             Z	dS )r   zFProvides a stream outputting the uncompressed offset delta informationc                 B    t                               | |||||f          S r   r   )r   r>   r   r   rH   rP   s         r   r   zODeltaPackStream.__new__   s!    }}S:tT:v"NOOOr   rT   c                 8    | d                              |          S N   rV   rX   s     r   rW   zODeltaPackStream.read   rY   r   c                     | d         S rh   r$   r%   s    r   rP   zODeltaPackStream.stream   r/   r   Nr[   rd   r$   r   r   r   r      sf        PPIP P P" " " "   X  r   r   c                      e Zd ZdZ e            ZddZddZed             Z	d Z
d Z ee
e          Zdd	Zd
 Zd Z eee          Zd Zd Z eee          Zd Zd Z eee          Zd Zd Z eee          ZdS )r   ag  Represents an input content stream to be fed into the ODB. It is mutable to allow
    the ODB to record information about the operations outcome right in this instance.

    It provides interfaces for the OStream and a StreamReader to allow the instance
    to blend in without prior conversion.

    The only method your content stream must support is 'read'Nc                 B    t                               | ||||d f          S r   )listr   )r   r   r   rP   r   s        r   r   zIStream.__new__   s!    ||C#tT64!@AAAr   c                 F    t                               | ||||d f           d S r   )rm   r   )r    r   r   rP   r   s        r   r   zIStream.__init__   s'    dS$fd;<<<<<r   c                 ,    t          | d                   S r)   r   r%   s    r   r*   zIStream.hexsha   r+   r   c                     | d         S )zD:return: the error that occurred when processing the stream, or Noneri   r$   r%   s    r   _errorzIStream._error   r/   r   c                     || d<   dS )zFSet this input stream to the given exc, may be None to reset the errorri   Nr$   )r    excs     r   
_set_errorzIStream._set_error   s    Qr   rT   c                 8    | d                              |          S )zhImplements a simple stream reader interface, passing the read call on
            to our internal streamrK   rV   rX   s     r   rW   zIStream.read   s     Aw||D!!!r   c                     || d<   d S rA   r$   )r    r&   s     r   _set_binshazIStream._set_binsha       Qr   c                     | d         S rA   r$   r%   s    r   _binshazIStream._binsha       Awr   c                     | d         S r-   r$   r%   s    r   _typezIStream._type   r{   r   c                     || d<   d S r-   r$   )r    r   s     r   	_set_typezIStream._set_type      Qr   c                     | d         S r4   r$   r%   s    r   _sizezIStream._size  r{   r   c                     || d<   d S r4   r$   rX   s     r   	_set_sizezIStream._set_size  r   r   c                     | d         S rJ   r$   r%   s    r   _streamzIStream._stream  r{   r   c                     || d<   d S rJ   r$   )r    rP   s     r   _set_streamzIStream._set_stream  rx   r   r   r[   )r6   r7   r8   r9   r   r:   r   r   r;   r*   rq   rt   errorrW   rw   rz   r&   r}   r   r   r   r   r   r   r   rP   r$   r   r   r   r      sw       B B IB B B B= = = = # # X#     HVZ((E" " " "     Xg{++F     8E9%%D     8E9%%D     Xg{++FFFr   r   c                   t    e Zd ZdZ e            Zd Zd Zed             Z	ed             Z
ed             ZdS )r   zCarries information about a sha identifying an object which is invalid in
    the queried database. The exception attribute provides more information about
    the cause of the issuec                 <    t                               | ||f          S r   r   )r   r   rs   s      r   r   zInvalidOInfo.__new__"  s    }}S3*---r   c                 @    t                               | ||f           d S r   r   )r    r   rs   s      r   r   zInvalidOInfo.__init__%  s     tc3Z(((((r   c                     | d         S rA   r$   r%   s    r   r&   zInvalidOInfo.binsha(  r/   r   c                 ,    t          | d                   S rA   r   r%   s    r   r*   zInvalidOInfo.hexsha,  s    $q'"""r   c                     | d         S )z2:return: exception instance explaining the failurer.   r$   r%   s    r   r   zInvalidOInfo.error0  r'   r   N)r6   r7   r8   r9   r   r:   r   r   r;   r&   r*   r   r$   r   r   r   r     s          I. . .) ) )   X # # X#   X  r   r   c                   &    e Zd ZdZ e            ZdS )r   z/Carries information about an invalid ODB streamN)r6   r7   r8   r9   r   r:   r$   r   r   r   r   6  s        99IIIr   r   N)r9   
gitdb.utilr   	gitdb.funr   r   __all__r   r   r   r	   r
   r]   r   r   rm   r   r   r   r$   r   r   <module>r      s  
 W V ! ! ! ! ! !       
8* * * * *E * * *\               J    Y   $    e   4    7   "    )   (    ~   $L, L, L, L, L,d L, L, L,b    5   6    \     r   