yL i-(ddgZddlmZddlmZddlmZddl m Z m Z m Z m Z ddlmZddlmZmZmZdd lmZmZmZer$dd lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#edZ$Gdde Z%Gdde%Z&y)Object IndexObjectN)WorkTreeRepositoryUnsupported) LazyMixin bin_to_hexjoin_path_native stream_copy)get_object_type_by_name)Any TYPE_CHECKINGUnion) AnyGitObjectGitObjectTypeStringPathLike)OStream) Reference)Repo)Blob) Submodule)Tree)rrrceZdZUdZdZdZejejejejfZ dZ dZ eedfed< ddd ed dffd Zeddd eed fd efdZeddded efdZded dffd Zded efdZded efdZd efdZd efdZd efdZ e!d efdZ"e!ddZ#ddZ$xZ%S)rarBase class for classes representing git object types. The following four leaf classes represent specific kinds of git objects: * :class:`Blob ` * :class:`Tree ` * :class:`Commit ` * :class:`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)repobinshasizeNtyperrrreturnct|||_||_t |dk(sJd|t |fzy)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__rrlen)selfrr __class__s V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/git/objects/base.pyr"zObject.__init__dsO   6{b  "P  KT #   idrc6|jt|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 :class:`~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_parsestr)clsrr(s r&newz Object.newws~~c"g&&r'sha1c||jk(rtd||S|jj|}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. scommit) NULL_BIN_SHAr odbinforrr)r,rr.oinfoinsts r& new_from_shazObject.new_from_shase 3## #5*95dDA A d#2&uzz24FJJ  r'attrc|dk(rA|jjj|j}|j|_yt ||y)zRetrieve object information.rN)rr1r2rrr! _set_cache_)r$r6r3r%s r&r8zObject._set_cache_s> 6>IIMM&&t{{3E DI G  %r'othercNt|dsy|j|jk(S)z3:return: ``True`` if the objects have the same SHA1rFhasattrrr$r9s r&__eq__z Object.__eq__s"uh'{{ell**r'cNt|dsy|j|jk7S)z::return: ``True`` if the objects do not have the same SHA1rTr;r=s r&__ne__z Object.__ne__s"uh'{{ell**r'c,t|jS)zE:return: Hash of our id allowing objects to be used in dicts and sets)hashrr$s r&__hash__zObject.__hash__sDKK  r'c|jS)z=:return: String of our SHA1 as understood by all git commands)hexsharCs r&__str__zObject.__str__s {{r'cPd|jjd|jdS)z::return: String with pythonic representation of our objectz)r%__name__rFrCs r&__repr__zObject.__repr__s"&.."9"94;;GGr'cJt|jjdS)z6:return: 40 byte hex version of our 20 byte binary shaascii)rrdecoderCs r&rFz Object.hexshas$++&--g66r'c`|jjj|jS)z :return: File-object compatible stream to the uncompressed raw data of the object :note: Returned streams must be read in order. )rr1streamrrCs r& data_streamzObject.data_streams!yy}}##DKK00r'c||jjj|j}t |||S)zWrite our data directly to the given output stream. :param ostream: File-object compatible stream object. :return: self )rr1rOrr )r$ostreamistreams r& stream_datazObject.stream_datas/))--&&t{{3GW% r')rr)rRrrr)&rI __module__ __qualname____doc__ NULL_HEX_SHAr0dbtyp str_blob_type str_tree_typestr_commit_type str_tag_typeTYPES __slots__rrr__annotations__bytesr" classmethodr+rr-r5r8r boolr>r@intrDrGrJpropertyrFrPrT __classcell__r%s@r&rr&slBLL      E+I-1D%#T) *1  V U t &'v'5k)9#:'|'' e "&&&+C+D+ +C+D+ !#!H#H777 11 r'c eZdZdZdZdZ ddddededefdede fd df fd Z d efd Z d e d dffd Z ed e fdZed e fdZxZS)ra}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. )pathmoderiNrrrrjrcLt||||||_|||_yy)aInitialize 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"rjri)r$rrrjrir%s r&r"zIndexObject.__init__s36 v&  DI  DI r'c,t|jS)z :return: Hash of our path as index items are uniquely identifiable by path, not by their data! )rBrirCs r&rDzIndexObject.__hash__s DIIr'r6c|tjvr%td|dt|jdt ||y)Nz Attribute 'z<' unset: path and mode attributes must have been set during z object creation)rr_AttributeErrorrrIr!r8)r$r6r%s r&r8zIndexObject._set_cache_sA ;(( ( d,,.  G  %r'c@tj|jS)zA:return: Name portion of the path, effectively being the basename)ospbasenamerirCs r&namezIndexObject.names||DII&&r'c|jj*t|jj|jSt 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. z"working_tree_dir was None or empty)rworking_tree_dirrrirrCs r&abspathzIndexObject.abspath s; 99 % % 1#DII$>$> J J/0TU Ur')NN)rIrUrVrWr__id_attribute_rarrdrr"rDr+r8rerrrurfrgs@r&rrs!IN "&&* D#I  D(N#   B#&&&'c'' V V Vr')'__all__os.pathrirp gitdb.typtyprYgit.excrgit.utilrrrr utilr typingr r r git.typesrrr gitdb.basergit.refs.referencergit.reporblobrsubmodule.basertreer IndexObjUnionrrr'r&rsp ] #1II)-,AA",)12 pYpfTV&TVr'