
    ch6                        S S/r SSKrSSKJr  SSKJrJrJr  SSK	J
r
  SSKJrJr  SSKJr  SS	KJrJr  SS
KJr  SSKJrJrJrJrJrJrJrJrJrJrJ r   \RB                  S:  a  SSKJ"r"  OSSK#J"r"  SSK$J%r%  \(       a  SSK&J'r'  SSK(J)r)  \\*\+\,4   r-\\\S   \\S   4      r.S\,S\,S\+4S jr/ " S S 5      r0 " S S\\Rb                  \
Rd                  \
Rf                  5      r4\4\4Rj                  \4Rl                  '   g)TreeModifierTree    N)IterableList	join_path
to_bin_sha   )util)IndexObjUnionIndexObject)Blob)tree_entries_from_datatree_to_stream)	Submodule)AnyCallableDictIterableIteratorListTupleTYPE_CHECKINGTypeUnioncast)      )Literal)PathLike)BytesIO)Repo)r   N)r   r   abreturnc                     X:  X:  -
  $ N )r!   r"   s     cC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\git/objects/tree.pycmpr(   6   s    Eae    c                       \ rS rSrSrSrS\\   SS4S jrS\	S\
4S	 jrSS
 jrSS\S\
S\	S\SS 4
S jjrS\S\
S\	SS4S jrS\	SS4S jrSrg)r   :   a  A 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.
_cachecacher#   Nc                     Xl         g r%   r,   )selfr.   s     r'   __init__TreeModifier.__init__E   s    r)   namec                 Z    [        U R                  5       H  u  p#US   U:X  d  M  Us  $    g)z7:return: index of an item with name, or -1 if not found   )	enumerater-   )r0   r3   its       r'   _index_by_nameTreeModifier._index_by_nameH   s,    dkk*DAtt| +
 r)   c                 :    U R                   R                  S S9  U $ )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
c                 P    U S   [         R                  S-  :X  a  U S   S-   $ U S   $ )Nr      r5   /)r   tree_id)xs    r'   <lambda>'TreeModifier.set_done.<locals>.<lambda>[   s/    qtt||r?Q7Q!s
'[WXYZW['[r)   )key)r-   sortr0   s    r'   set_doneTreeModifier.set_doneR   s     	[\r)   shamodeforcec                    SU;   a  [        S5      eUS-	  [        R                  ;  a  [        SU-  5      e[        U5      nU R	                  U5      nXU4nUS:X  a  U R
                  R                  U5        U $ U(       a  X`R
                  U'   U $ U R
                  U   nUS   U:w  d	  US   U:w  a  [        SU-  5      eU $ )	a4  Add 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 %or6   r   r   z)Item %r existed with different properties)
ValueErrorr   _map_id_to_typer   r:   r-   append)r0   rI   rJ   r3   rK   indexitemex_items           r'   addTreeModifier.adda   s    ( $;CDDBJt333G$NOOo##D)4 B;KKt$  %)E"  ++e,1:$
d(:$%PSW%WXX r)   binshac                     [        U[        5      (       a*  [        U[        5      (       a  [        U[        5      (       d   eXU4nU R                  R                  U5        g)zAdd 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)
isinstancebytesintstrr-   rO   )r0   rU   rJ   r3   
tree_caches        r'   add_uncheckedTreeModifier.add_unchecked   sM     &%((Zc-B-BzRVX[G\G\\\D)
:&r)   c                 N    U R                  U5      nUS:  a  U R                  U	 gg)z0Delete an item with the given name if it exists.r6   N)r:   r-   )r0   r3   rP   s      r'   __delitem__TreeModifier.__delitem__   s*    ##D)2:E" r)   )r#   r   )F)__name__
__module____qualname____firstlineno____doc__	__slots__r   TreeCacheTupr1   rZ   rY   r:   rG   rX   boolrS   r\   r_   __static_attributes__r&   r)   r'   r   r   :   s     Id<0 T 3 3 
*u *C *s *4 *N *X'E ' 'C 'D '# # #r)   c                     ^  \ rS rSr% SrSr\S   \S'   SrSr	Sr
SrS	r\	\\
\\\0r\\\\   4   \S
'   \S-  S4SSS\S\S\\S4   4U 4S jjjr\S\S\\S   \S   4   4S j5       rS\SS4U 4S jjrS\\   S\\   4S jr S\S\4S jr!S\S\4S jr"\#S\$S    4S j5       r%\#S\$\   4S  j5       r&\#S\'4S! j5       r(S" S# S$S%S&S'S&4S(\)\\\*4   \/\+4   S)\)\\\*4   \/\+4   S*\S+\+S,\+S-\S.\+S\\\   \\*   4   4U 4S/ jjjr,S0\-S1\-S\.\   4U 4S2 jjr/S3\S4\S\$\   4S5 jr0S\\   4S6 jr1S\4S7 jr2S8\\\\34   S\4S9 jr4S8\\\4   S\+4S: jr5S\\   4S; jr6S>S< jr7S>S= jr8Sr9U =r:$ )?r      a  Tree 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]``.
treetyper,      r   
      rN   r>   Nrepor    rU   rJ   pathc                 &   > [         TU ]  XX45        g r%   )superr1   )r0   rq   rU   rJ   rr   	__class__s        r'   r1   Tree.__init__   s     	t2r)   index_objectr#   )r   .r&   c                 l    UR                   S:X  a$  [        UR                  UR                  5      5      $ g)Nrl   r&   )rm   tuple_iter_convert_to_objectr-   )clsrw   s     r'   _get_intermediate_itemsTree._get_intermediate_items   s1    
 &==l>Q>QRSSr)   attrc                    > US:X  aN  U R                   R                  R                  U R                  5      n[	        UR                  5       5      U l        g [        TU ]!  U5        g )Nr-   )	rq   odbstreamrU   r   readr-   rt   _set_cache_)r0   r~   ostreamru   s      r'   r   Tree._set_cache_   sF    8iimm**4;;7G.DW\\^.TDKG%r)   iterablec              #      #    U HC  u  p#n[        U R                  U5      n U R                  US-	     " U R                  X#U5      v   ME     g! [         a  n[        SX54-  5      UeSnAff = f7f)zqIterable 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)r   rr   rN   rq   KeyError	TypeError)r0   r   rU   rJ   r3   rr   es          r'   rz   Tree._iter_convert_to_object   sz      #+F$TYY-Dj**42:6tyy&PTUU #+  j RVZUa abhiijs(   A/&AA/
A,A''A,,A/filec                    SnSU;   av  U nU nUR                  S5      n[        U5       H>  u  pgX7   nUR                  S:X  a  UnM  U[        U5      S-
  :w  a  [	        X!-  5      eUs  $    X@:X  a  [	        X!-  5      eU$ U R
                   HS  nUS   U:X  d  M  U R                  US   S-	     " U R                  US   US   [        U R                  US   5      5      s  $    [	        X!-  5      e)zFind 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.
zBlob or Tree named %r not foundr?   rl   r   r5   r>   r   )
splitr7   rm   lenr   r-   rN   rq   r   rr   )	r0   r   msgrl   rQ   tokensr8   tokeninfos	            r'   join	Tree.join   s     0$;DDZZ_F%f-{99&D CK!O+&sz22K . |sz**K7d?//Q2>		47DGYtyy$q'5R  $ 3:&&r)   c                 $    U R                  U5      $ )zQThe ``/`` operator is another syntax for joining.

See :meth:`join` for details.
)r   )r0   r   s     r'   __truediv__Tree.__truediv__  s    
 yyr)   c                 T    U  Vs/ s H  oR                   S:X  d  M  UPM     sn$ s  snf )z?:return: list(Tree, ...) List of trees directly below this treerl   rm   r0   r8   s     r'   trees
Tree.trees  %      44a66V#34444   %%c                 T    U  Vs/ s H  oR                   S:X  d  M  UPM     sn$ s  snf )z?:return: list(Blob, ...) List of blobs directly below this treeblobr   r   s     r'   blobs
Tree.blobs  r   r   c                 ,    [        U R                  5      $ )aX  
: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.
)r   r-   rF   s    r'   r.   
Tree.cache!  s     DKK((r)   c                     g)NTr&   r8   ds     r'   rB   Tree.<lambda>1  s    `dr)   c                     g)NFr&   r   s     r'   rB   r   2  s    \ar)   r6   TFr   	predicateprunedepthbranch_first
visit_onceignore_selfas_edgec                 ~   > [        [        [        [           [        [           4   [
        TU ]  UUUUUU5      5      $ )zFor documentation, see
`Traversable._traverse() <git.objects.util.Traversable._traverse>`.

Trees are set to ``visit_once = False`` to gain more performance in the
traversal.
)r   r   r   r
   TraversedTreeTuprt   	_traverse)	r0   r   r   r   r   r   r   r   ru   s	           r'   traverseTree.traverse/  sI    6 (=)84D+EEFG

 
	
r)   argskwargsc                 $   > [         TU ]  " U0 UD6$ )z
:return:
    :class:`~git.util.IterableList` with the results of the traversal as
    produced by :meth:`traverse`

    Tree -> IterableList[Union[Submodule, Tree, Blob]]
)rt   _list_traverse)r0   r   r   ru   s      r'   list_traverseTree.list_traverseV  s     w%t6v66r)   r8   jc                 N    [        U R                  U R                  X 5      5      $ r%   )listrz   r-   )r0   r8   r   s      r'   __getslice__Tree.__getslice__b  s!    D00Q1ABCCr)   c                 8    U R                  U R                  5      $ r%   )rz   r-   rF   s    r'   __iter__Tree.__iter__e  s    ++DKK88r)   c                 ,    [        U R                  5      $ r%   )r   r-   rF   s    r'   __len__Tree.__len__h  s    4;;r)   rQ   c           
      <   [        U[        5      (       aT  U R                  U   nU R                  US   S-	     " U R                  US   US   [        U R                  US   5      5      $ [        U[        5      (       a  U R                  U5      $ [        SU-  5      e)Nr   r>   r   r5   zInvalid index type: %r)
rW   rY   r-   rN   rq   r   rr   rZ   r   r   )r0   rQ   r   s      r'   __getitem__Tree.__getitem__k  s    dC  ;;t$D''Q26tyy$q'4PQ7T]^b^g^gimnoipTqrrdC  99T?" 04788r)   c                     [        U[        5      (       a)  U R                   H  nUR                  US   :X  d  M    g   gU R                  nU R                   H  nU[        X2S   5      :X  d  M    g   g)Nr   Tr5   F)rW   r   r-   rU   rr   r   )r0   rQ   r   rr   s       r'   __contains__Tree.__contains__w  sg    dK((;;$q') $  99D9T733 $ r)   c                 J    [        U R                  U R                  5      5      $ r%   )reversedrz   r-   rF   s    r'   __reversed__Tree.__reversed__  s    44T[[ABBr)   c                 F    [        U R                  UR                  5        U $ )a  Serialize 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.
)r   r-   writer0   r   s     r'   
_serializeTree._serialize  s     	t{{FLL1r)   c                 B    [        UR                  5       5      U l        U $ r%   )r   r   r-   r   s     r'   _deserializeTree._deserialize  s    ,V[[];r)   )r   r   r#   r   );ra   rb   rc   rd   re   rm   r   __annotations__rf   	commit_idblob_id
symlink_idr@   r   r   rN   r   rY   r   r
   rX   r   r   r1   classmethodr   r|   rZ   r   r   rg   r   rz   r   r   propertyr   r   r   r   r.   r   r   rh   r   r   r   r   r   r   r   slicer   r   r   r   r   ri   __classcell__)ru   s   @r'   r   r      s
   
 #D'&/"I IGJG 	9D7OT#tM223  rM&*33 3 	3
 HdN#3 3 # 
u[!59,	- & & &	j0F 	j8TaKb 	j$' $' $'N   5tF| 5 5 5tDz 5 5 )| ) ) TeOa! %
U=2B#BCSI4OP%
 }.>>?EtKL%
 	%

 %
 %
 %
 %
 
x&1A(BB	C%
 %
N73 7# 7,}:U 7Dc Dc Dd=.A D9(=1 9   
9c3o 6 
9= 
9}h'>!? D &Ch}5 C	 r)   )7__all__sysgit.diffdiffgit_diffgit.utilr   r   r    r	   baser
   r   r   r   funr   r   submodule.baser   typingr   r   r   r   r   r   r   r   r   r   r   version_infor   typing_extensions	git.typesr   ior   git.repor    rX   rY   rZ   rg   r   r(   r   DiffableTraversableSerializabler   rN   r@   r&   r)   r'   <module>r      s    6
" 
  8 8  ,  7 %    v) UC_%u\2M5IaCbbcd 
3 3 3 e# e#Tv;))4+;+;T=N=N vx &*  T\\ "r)   