yL i6ddgZddlZddlmZddlmZmZmZddl m Z ddl m Z m Z ddlmZdd lmZmZdd lmZdd lmZmZmZmZmZmZmZmZmZmZm Z ejBd k\rdd lm"Z"ndd l#m"Z"ddl$m%Z%er ddl&m'Z'ddl(m)Z)ee*e+e,fZ-eeede edfZ.de,de,de+fdZ/GddZ0Gdde ejbe jde jfZ4e4e4jje4jl<y) TreeModifierTreeN) IterableList join_path to_bin_sha)util) IndexObjUnion IndexObject)Blob)tree_entries_from_datatree_to_stream) Submodule) AnyCallableDictIterableIteratorListTuple TYPE_CHECKINGTypeUnioncast))Literal)PathLike)BytesIO)Repo)rN)rrabreturnc||kD||kz SN)r!r"s V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/git/objects/tree.pycmpr(6s Ea!e c eZdZdZdZdeeddfdZdede fdZ dd Z dd e d e ded e ddf d Zde d e deddfdZdeddfdZy)raA utility class providing methods to alter the underlying cache in a list-like fashion. Once all adjustments are complete, the :attr:`_cache`, which really is a reference to the cache of a tree, will be sorted. This ensures it will be in a serializable state. _cachecacher#Nc||_yr%r+)selfr-s r'__init__zTreeModifier.__init__Es  r)namecVt|jD]\}}|d|k(s|cSy)z7:return: index of an item with name, or -1 if not found) enumerater,)r/r1its r'_index_by_namezTreeModifier._index_by_nameHs3dkk* DAqtt|  r)c@|jjd|S)zCall this method once you are done modifying the tree information. This may be called several times, but be aware that each call will cause a sort operation. :return: self cN|dtjdzk(r|ddzS|dS)Nr r3/)rtree_id)xs r'z'TreeModifier.set_done..[s-qtt||r?Q7Q!s WXYZW[r))key)r,sortr/s r'set_donezTreeModifier.set_doneRs [\ r)shamodeforcecpd|vr td|dz tjvrtd|zt|}|j |}|||f}|dk(r|j j ||S|r||j |<|S|j |}|d|k7s|d|k7rtd|z|S) aAdd the given item to the tree. If an item with the given name already exists, nothing will be done, but a :exc:`ValueError` will be raised if the sha and mode of the existing item do not match the one you add, unless `force` is ``True``. :param sha: The 20 or 40 byte sha of the item to add. :param mode: :class:`int` representing the stat-compatible mode of the item. :param force: If ``True``, an item with your name and information will overwrite any existing item with the same name, no matter which information it has. :return: self r<z$Name must not contain '/' charactersr;z(Invalid object type according to mode %or4rrz)Item %r existed with different properties) ValueErrorr_map_id_to_typerr8r,append)r/rDrEr1rFindexitemex_items r'addzTreeModifier.addas( $;CD D BJt33 3G$NO Oo##D)T4  B; KK  t $ %) E" ++e,1:$ d(:$%PSW%WXX r)binshact|tr t|trt|tsJ|||f}|jj |y)aAdd the given item to the tree. Its correctness is assumed, so it is the caller's responsibility to ensure that the input is correct. For more information on the parameters, see :meth:`add`. :param binsha: 20 byte binary sha. N) isinstancebytesintstrr,rJ)r/rOrEr1 tree_caches r' add_uncheckedzTreeModifier.add_uncheckedsF&%(Zc-BzRVX[G\\\dD)  :&r)cL|j|}|dkDr|j|=yy)z0Delete an item with the given name if it exists.r4N)r8r,)r/r1rKs r' __delitem__zTreeModifier.__delitem__s*##D) 2: E" r))r#r)F)__name__ __module__ __qualname____doc__ __slots__r TreeCacheTupr0rTrSr8rCrRboolrNrVrXr&r)r'rr:sId<0T33 *u*C*s*4*N*X 'E ' 'C 'D '###r)ceZdZUdZdZeded<dZdZdZ dZ dZ ee e e e e iZeeeefed <e d zd fd d dededeed fffd ZededeededffdZdedd ffd ZdeedeefdZdedefdZ dedefdZ!e"de#dfdZ$e"de#e fdZ%e"de&fd Z'd!d"d#d$d%d&d%fd'e(eee)fege*fd(e(eee)fege*fd)ed*e*d+e*d,ed-e*deeeee)fffd. Z+d/e,d0e,de-effd1 Z.d2ed3ede#efd4Z/deefd5Z0defd6Z1d7eeee2fdefd8Z3d7eeefde*fd9Z4deefd:Z5d=d;Z6d=d<Z7xZ8S)>raTree objects represent an ordered list of :class:`~git.objects.blob.Blob`\s and other :class:`Tree`\s. See :manpage:`gitglossary(7)` on "tree object": https://git-scm.com/docs/gitglossary#def_tree_object Subscripting is supported, as with a list or dict: * Access a specific blob using the ``tree["filename"]`` notation. * You may likewise access by index, like ``blob = tree[0]``. treetyper+r rIr;Nrepor rOrEpathc*t|||||yr%)superr0)r/rfrOrErg __class__s r'r0z Tree.__init__s vtT2r) index_objectr#)r.r&cj|jdk(r$t|j|jSy)Nrar&)rbtuple_iter_convert_to_objectr,)clsrks r'_get_intermediate_itemszTree._get_intermediate_itemss1    &==l>Q>QRS Sr)attrc|dk(rN|jjj|j}t |j |_yt|!|y)Nr,) rfodbstreamrOr readr,ri _set_cache_)r/rqostreamrjs r'rvzTree._set_cache_sF 8 iimm**4;;7G.DW\\^.TDK G  %r)iterablec#K|D]D\}}}t|j|} |j|dz |j|||Fy#t$r}t d||fz|d}~wwxYww)zIterable yields tuples of (binsha, mode, name), which will be converted to the respective object representation. r;z0Unknown mode %o found in tree data for path '%s'N)rrgrIrfKeyError TypeError)r/rxrOrEr1rges r'rnzTree._iter_convert_to_objects#+ j FD$TYY-D j6d**42:6tyy&$PTUU j j RVZ\`Ua abhii js( A/'A  A/ A,A''A,,A/filec d}d|vrv|}|}|jd}t|D]>\}}||}|jdk(r|}|t|dz k7rt ||z|cS||k(rt ||z|S|j D]Q}|d|k(s |j |ddz |j|d|dt|j|dcSt ||z)a Find the named object in this tree's contents. :return: :class:`~git.objects.blob.Blob`, :class:`Tree`, or :class:`~git.objects.submodule.base.Submodule` :raise KeyError: If the given file or tree does not exist in this tree. zBlob or Tree named %r not foundr<rarr3r;r) splitr5rblenrzr,rIrfrrg) r/r}msgrarLtokensr6tokeninfos r'joinz Tree.joins0 $;DDZZ_F%f- 5E{99&DCK!O+&sTz22K t|sTz**K  7d?>4//Q2 > 47DGYtyy$q'5R  3:& &r)c$|j|S)zaThe ``/`` operator is another syntax for joining. See :meth:`join` for details. )r)r/r}s r' __truediv__zTree.__truediv__s yyr)cL|Dcgc]}|jdk(s|c}Scc}w)z?:return: list(Tree, ...) List of trees directly below this treerarbr/r6s r'treesz Tree.trees# 4a166V#3444!!cL|Dcgc]}|jdk(s|c}Scc}w)z?:return: list(Blob, ...) List of blobs directly below this treeblobrrs r'blobsz Tree.blobsrrc,t|jS)a :return: An object allowing modification of the internal cache. This can be used to change the tree's contents. When done, make sure you call :meth:`~TreeModifier.set_done` on the tree modifier, or serialization behaviour will be incorrect. :note: See :class:`TreeModifier` for more information on how to alter the cache. )rr,rBs r'r-z Tree.cache!sDKK((r)cy)NTr&r6ds r'r?z Tree.1r)cy)NFr&rs r'r?z Tree.2rr)r4TFr predicateprunedepth branch_first visit_once ignore_selfas_edgec ~ttttttft |||||||S)zFor documentation, see `Traversable._traverse() `. Trees are set to ``visit_once = False`` to gain more performance in the traversal. )rrrr TraversedTreeTupri _traverse) r/rrrrrrrrjs r'traversez Tree.traverse/sI6 (=)84D+EE F G     r)argskwargsc"t||i|S)z :return: :class:`~git.util.IterableList` with the results of the traversal as produced by :meth:`traverse` Tree -> IterableList[Union[Submodule, Tree, Blob]] )ri_list_traverse)r/rrrjs r' list_traversezTree.list_traverseVsw%t6v66r)r6jcPt|j|j||Sr%)listrnr,)r/r6rs r' __getslice__zTree.__getslice__bs#D00Qq1ABCCr)c8|j|jSr%)rnr,rBs r'__iter__z Tree.__iter__es++DKK88r)c,t|jSr%)rr,rBs r'__len__z Tree.__len__hs4;;r)rLc (t|trT|j|}|j|ddz |j|d|dt |j |dSt|tr|j|Std|z)Nrr;rr3zInvalid index type: %r) rQrSr,rIrfrrgrTrr{)r/rLrs r' __getitem__zTree.__getitem__ks dC ;;t$D64''Q2 6tyy$q'4PQ7T]^b^g^gimnoipTqr r dC 99T? "04788r)ct|tr&|jD]}|j|dk(syy|j}|jD]}|t ||dk(syy)NrTr3F)rQr r,rOrgr)r/rLrrgs r' __contains__zTree.__contains__wsp dK (  ;;$q')  99D  9T4733 r)cJt|j|jSr%)reversedrnr,rBs r' __reversed__zTree.__reversed__s44T[[ABBr)cFt|j|j|S)a9Serialize this tree into the stream. Assumes sorted tree data. :note: We will assume our tree data to be in a sorted state. If this is not the case, serialization will not generate a correct tree representation as these are assumed to be sorted by algorithms. )rr,writer/rts r' _serializezTree._serializes t{{FLL1 r)cBt|j|_|Sr%)r rur,rs r' _deserializezTree._deserializes,V[[];  r))rtrr#r)9rYrZr[r\rbr__annotations__r] commit_idblob_id symlink_idr=rr rIrrSrr rRrrr0 classmethodrrprTrvrr^rrnrrpropertyrrrrr-rrr_rrrrrrrslicerrrrr __classcell__)rjs@r'rrs #D'&/"IIGJG 9D7OT#tM223rM&* 333 3 HdN# 3# u[!59, -&&& j0F j8TaKb j$'$'$'N 5tF|555tDz55 )| ) )TeOa! % U=2B#BCSI4OP% }.>>?EtKL%  %  %  % % %  x &1A(BB C% N737#7,}:U7DcDcDd=.AD9(=19   9c3o 6 9= 9}h'>!?D&Ch}5C r))7__all__sysgit.diffdiffgit_diffgit.utilrrrr baser r rr funr rsubmodule.basertypingrrrrrrrrrrr version_infortyping_extensions git.typesriorgit.repor rRrSrTr^rr(rDiffable Traversable SerializablerrIr=r&r)r'rs 6 " 88,7%    v)UC_% u\2M5IaCbbcd 333e#e#Tv;))4+;+;T=N=Nvx&*T\\"r)