
    .Ph%(                        d dgZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZ ddlmZ ddlmZmZmZ dd	lmZmZmZ er$dd
lmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ed         Z$ G d d e
          Z% G d de%          Z&dS )ObjectIndexObject    N)WorkTreeRepositoryUnsupported)	LazyMixin
bin_to_hexjoin_path_nativestream_copy   )get_object_type_by_name)AnyTYPE_CHECKINGUnion)AnyGitObjectGitObjectTypeStringPathLike)OStream)	Reference)Repo)Blob)	Submodule)Tree)r   r   r   c                   ~    e Zd ZU dZdZdZej        ej        ej	        ej
        fZdZdZeedf         ed<   	 ddd	ed
df fdZedddeedf         d
efd            Zeddded
efd            Zded
df fdZded
efdZded
efdZd
efdZd
efdZd
efdZ e!d
efd            Z"e!dd            Z#ddZ$ xZ%S ) r   ar  Base class for classes representing git object types.

    The following four leaf classes represent specific kinds of git objects:

    * :class:`Blob <git.objects.blob.Blob>`
    * :class:`Tree <git.objects.tree.Tree>`
    * :class:`Commit <git.objects.commit.Commit>`
    * :class:`TagObject <git.objects.tag.TagObject>`

    See :manpage:`gitglossary(7)` on:

    * "object": https://git-scm.com/docs/gitglossary#def_object
    * "object type": https://git-scm.com/docs/gitglossary#def_object_type
    * "blob": https://git-scm.com/docs/gitglossary#def_blob_object
    * "tree object": https://git-scm.com/docs/gitglossary#def_tree_object
    * "commit object": https://git-scm.com/docs/gitglossary#def_commit_object
    * "tag object": https://git-scm.com/docs/gitglossary#def_tag_object

    :note:
        See the :class:`~git.types.AnyGitObject` union type of the four leaf subclasses
        that represent actual git object types.

    :note:
        :class:`~git.objects.submodule.base.Submodule` is defined under the hierarchy
        rooted at this :class:`Object` class, even though submodules are not really a
        type of git object. (This also applies to its
        :class:`~git.objects.submodule.root.RootModule` subclass.)

    :note:
        This :class:`Object` class should not be confused with :class:`object` (the root
        of the class hierarchy in Python).
    (0000000000000000000000000000000000000000s                       )repobinshasizeNtyper   r   r   returnc                     t                                                       || _        || _        t	          |          dk    sJ d|t	          |          fz              dS )zInitialize an object by identifying it by its binary sha.

        All keyword arguments will be set on demand if ``None``.

        :param repo:
            Repository this object is located in.

        :param binsha:
            20 byte SHA1
           z,Require 20 byte binary sha, got %r, len = %iN)super__init__r   r   len)selfr   r   	__class__s      P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/git/objects/base.pyr"   zObject.__init__d   sf     		6{{b   "PKKT
 #
         idr   c                 F    |                     t          |                    S )a"  
        :return:
            New :class:`Object` instance of a type appropriate to the object type behind
            `id`. The id of the newly created object will be a binsha even though the
            input id may have been a `~git.refs.reference.Reference` or rev-spec.

        :param id:
            :class:`~git.refs.reference.Reference`, rev-spec, or hexsha.

        :note:
            This cannot be a ``__new__`` method as it would always call :meth:`__init__`
            with the input id which is not necessarily a binsha.
        )	rev_parsestr)clsr   r(   s      r&   newz
Object.neww   s     ~~c"gg&&&r'   sha1c                     || j         k    r t          d          ||          S |j                            |          } t          |j                  ||j                  }|j        |_        |S )z
        :return:
            New object instance of a type appropriate to represent the given binary sha1

        :param sha1:
            20 byte binary sha1.
        s   commit)NULL_BIN_SHAr   odbinfor   r   r   )r,   r   r.   oinfoinsts        r&   new_from_shazObject.new_from_sha   sl     3###5*955dDAAAd##2&uz224FFJ	r'   attrc                     |dk    r2| j         j                            | j                  }|j        | _        dS t                                          |           dS )zRetrieve object information.r   N)r   r1   r2   r   r   r!   _set_cache_)r$   r6   r3   r%   s      r&   r8   zObject._set_cache_   sP    6>>IM&&t{33E
DIIIGG%%%%%r'   otherc                 F    t          |d          sdS | j        |j        k    S )z3:return: ``True`` if the objects have the same SHA1r   Fhasattrr   r$   r9   s     r&   __eq__zObject.__eq__   s(    uh'' 	5{el**r'   c                 F    t          |d          sdS | j        |j        k    S )z::return: ``True`` if the objects do not have the same SHA1r   Tr;   r=   s     r&   __ne__zObject.__ne__   s(    uh'' 	4{el**r'   c                 *    t          | j                  S )zE:return: Hash of our id allowing objects to be used in dicts and sets)hashr   r$   s    r&   __hash__zObject.__hash__   s    DK   r'   c                     | j         S )z=:return: String of our SHA1 as understood by all git commands)hexsharC   s    r&   __str__zObject.__str__   s
    {r'   c                 2    d| j         j        d| j        dS )z::return: String with pythonic representation of our objectz<git.z "z">)r%   __name__rF   rC   s    r&   __repr__zObject.__repr__   s      "&."9"9"94;;;GGr'   c                 P    t          | j                                      d          S )z6:return: 40 byte hex version of our 20 byte binary shaascii)r   r   decoderC   s    r&   rF   zObject.hexsha   s"     $+&&--g666r'   r   c                 J    | j         j                            | j                  S )z
        :return:
            File-object compatible stream to the uncompressed raw data of the object

        :note:
            Returned streams must be read in order.
        )r   r1   streamr   rC   s    r&   data_streamzObject.data_stream   s     y}##DK000r'   ostreamc                 n    | j         j                            | j                  }t	          ||           | S )zWrite our data directly to the given output stream.

        :param ostream:
            File-object compatible stream object.

        :return:
            self
        )r   r1   rO   r   r	   )r$   rQ   istreams      r&   stream_datazObject.stream_data   s2     )-&&t{33GW%%%r'   )r   r   )rQ   r   r   r   )&rI   
__module____qualname____doc__NULL_HEX_SHAr0   dbtypstr_blob_typestr_tree_typestr_commit_typestr_tag_typeTYPES	__slots__r   r   r   __annotations__bytesr"   classmethodr+   r   r-   r5   r8   r   boolr>   r@   intrD   rG   rJ   propertyrF   rP   rT   __classcell__r%   s   @r&   r   r   &   sH         B LL 		E +I-1D%#T)
*111
V 
U 
t 
 
 
 
 
 
& 'v '5k)9#: '| ' ' ' ['   e     ["& & & & & & & &+C +D + + + ++C +D + + + +!# ! ! ! !    H# H H H H 7 7 7 7 X7
 1 1 1 X1       r'   c                        e Zd ZdZdZdZ	 	 ddddededef         dede	f         d	df
 fd
Z
d	efdZded	df fdZed	efd            Zed	e	fd            Z xZS )r   a|  Base for all objects that can be part of the index file.

    The classes representing git object types that can be part of the index file are
    :class:`~git.objects.tree.Tree and :class:`~git.objects.blob.Blob`. In addition,
    :class:`~git.objects.submodule.base.Submodule`, which is not really a git object
    type but can be part of an index file, is also a subclass.
    )pathmoderi   Nr   r   r   rj   r   c                 t    t                                          ||           ||| _        |	|| _        dS dS )a  Initialize a newly instanced :class:`IndexObject`.

        :param repo:
            The :class:`~git.repo.base.Repo` we are located in.

        :param binsha:
            20 byte sha1.

        :param mode:
            The stat-compatible file mode as :class:`int`.
            Use the :mod:`stat` module to evaluate the information.

        :param path:
            The path to the file in the file system, relative to the git repository
            root, like ``file.ext`` or ``folder/other.ext``.

        :note:
            Path may not be set if the index object has been created directly, as it
            cannot be retrieved without knowing the parent tree.
        N)r!   r"   rj   ri   )r$   r   r   rj   ri   r%   s        r&   r"   zIndexObject.__init__   sE    6 	v&&&DIDIII r'   c                 *    t          | j                  S )z
        :return:
            Hash of our path as index items are uniquely identifiable by path, not by
            their data!
        )rB   ri   rC   s    r&   rD   zIndexObject.__hash__  s     DIr'   r6   c                     |t           j        v r(t          d|dt          |           j        d          t                                          |           d S )NzAttribute 'z<' unset: path and mode attributes must have been set during z object creation)r   r_   AttributeErrorr   rI   r!   r8   )r$   r6   r%   s     r&   r8   zIndexObject._set_cache_  sb    ;((( .44d,,,.  
 GG%%%%%r'   c                 4    t          j        | j                  S )zA:return: Name portion of the path, effectively being the basename)ospbasenameri   rC   s    r&   namezIndexObject.name  s     |DI&&&r'   c                 v    | j         j        t          | j         j        | j                  S t	          d          )a&  
        :return:
            Absolute path to this index object in the file system (as opposed to the
            :attr:`path` field which is a path relative to the git repository).

            The returned path will be native to the system and contains ``\`` on
            Windows.
        Nz"working_tree_dir was None or empty)r   working_tree_dirr   ri   r   rC   s    r&   abspathzIndexObject.abspath   s5     9%1#DI$>	JJJ/0TUUUr'   )NN)rI   rU   rV   rW   r_   _id_attribute_ra   r   rd   r   r"   rD   r+   r8   re   rr   ru   rf   rg   s   @r&   r   r      sC         !I N "&&*   D#I	
 D(N# 
     B#    & & & & & & & & 'c ' ' ' X' V V V V XV V V V Vr'   )'__all__os.pathri   rp   	gitdb.typtyprY   git.excr   git.utilr   r   r   r	   utilr   typingr   r   r   	git.typesr   r   r   
gitdb.baser   git.refs.referencer   git.repor   blobr   submodule.baser   treer   IndexObjUnionr   r    r'   r&   <module>r      s   ]
#             1 1 1 1 1 1 I I I I I I I I I I I I ) ) ) ) ) ) - , , , , , , , , , A A A A A A A A A A """""",,,,,,))))))12
p p p p pY p p pfTV TV TV TV TV& TV TV TV TV TVr'   