
    64%eV              	          d Z ddlmZmZ ddlZddlmZmZmZ ddl	Z	ddl
mZ ddlmZ ddlZddlZddlmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z! dd	l"m#Z#m$Z$m%Z% er7dd
l&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl"m6Z6m7Z7 neZ6d Z7 G d de          Z8 edd          Z9e ee d         df         df         Z:dZ; ed          Z<de e=e>f         de?fdZ@d e=de ed!         ed"         ed#         ed$         f         fd%ZAd&e>de?fd'ZBd(eCde>fd)ZDd*e>de>fd+ZE G d, d-e          ZF eFdd.          ZGd/eCd0eCdefd1ZHd2e e>ef         dee?e?f         fd3ZI e	jJ        d4          ZK e	jJ        d5          ZLd6e>deee?e?f         fd7ZM G d8 d9eN          ZOe7 G d: de6                      ZPe7 G d; d<e6                      ZQ G d= deeP          ZRdS )>z$Module for general utility functions    )ABCabstractmethodN)IterableListIterableObjActor)deque)digits)datetime	timedeltatzinfo)AnyCallableDequeIteratorGeneric
NamedTupleoverloadSequenceTYPE_CHECKINGTupleTypeTypeVarUnioncast)Has_id_attributeLiteral_T)BytesIOStringIO   )Commit)Blob)	TagObject)TreeTraversedTreeTup)Popen)	Submodule)Protocolruntime_checkablec                     | S N )fs    0lib/python3.11/site-packages/git/objects/util.pyr)   r)   7   s        c                   F    e Zd ZU eed<   ed         ed<   ed         ed<   dS )
TraverseNTdepthTraversabler"   itemr4   NsrcN)__name__
__module____qualname__int__annotations__r   r,   r/   r.   r1   r1   ;   s?         JJJ
%
&&&&	"	######r/   r1   T_TIobjTraversableIterableObj)boundr6   r4   r%   )get_object_type_by_name
parse_dateparse_actor_and_dateProcessStreamAdapterr4   altz_to_utctz_strutctz_to_altzverify_utctzr   tzoffsetutcmodestrreturnc                     d}t          t          | dd                             D ]D\  }}t          t          t          t
          f         |          }|t          |          |dz  z  z  }E|S )a_  
    :param modestr: string like 755 or 644 or 100644 - only the last 6 chars will be used
    :return:
        String identifying a mode compatible to the mode methods ids of the
        stat module regarding the rwx permissions for user, group and other,
        special flags and file system flags, i.e. whether it is a symlink
        for example.r   N   )	enumeratereversedr   r   strr;   )rI   mode	iterationchars       r.   mode_str_to_intrT   ]   sk     D$Xgbccl%;%;<< + +	4E#s(OT**D		Y]**Kr/   object_type_namer!   r#   r$   r"   c                     | dk    rddl m} |j        S | dk    rddl m} |j        S | dk    rddl m} |j        S | dk    rdd	l m} |j        S t          d
| 
                                z            )z
    :return: type suitable to handle the given object type name.
        Use the type to create new instances.

    :param object_type_name: Member of TYPES

    :raise ValueError: In case object_type_name is unknowns   commitr    )commits   tag)tags   blob)blobs   tree)treez%Cannot handle unknown object type: %s) rW   r!   rX   r#   rY   r"   rZ   r$   
ValueErrordecode)rU   rW   rX   rY   rZ   s        r.   r@   r@   m   s     9$$}	V	#	#}	W	$	$y	W	$	$y@CSCZCZC\C\\]]]r/   utctzc                     t          |           }t          |          dz  dz  t          |          dz  dz  z   }|dk     r|n| S )zConvert a git timezone offset into a timezone offset west of
    UTC in seconds (compatible with time.altzone).

    :param utctz: git utc timezone string, i.e. +0200
    d     <   r   )r;   abs)r^   	int_utctzsecondss      r.   rE   rE      sM     E

I9~~$,I0D/JJG!mm77'1r/   altzc                     t          |           dz  }t          |           dz  dz  }| dk    rdnd}d                    |||          S )zConvert a timezone offset west of UTC in seconds into a git timezone offset string

    :param altz: timezone offset in seconds west of UTC
    ra   rb   -+z{}{:02}{:02})rc   format)rf   hoursminutessigns       r.   rD   rD      sR    
 IIE4yy4B&G"**33#D  ug666r/   offsetc                     t          d| z            }t          |           dk    r|| d         dvr|| d         t          vs-| d         t          vs| d         t          vs| d         t          vr|| S )	z=:raise ValueError: if offset is incorrect
    :return: offsetz"Invalid timezone offset format: %s   r   z+-r       rM      )r\   lenr	   )rn   fmt_excs     r.   rF   rF      s     =FGGG
6{{aayay&)6"9"9VAYf=T=TX^_`XaioXoXoMr/   c                       e Zd Zddededef         ddfdZdeed          eeef         f         fdZ	dee
df         defdZdee
df         defd	Zdee
df         defd
ZdS )rG   Nsecs_west_of_utcnamerJ   c                 D    t          |           | _        |pd| _        d S )N)re   fixed)r   _offset_name)selfrv   rw   s      r.   __init__ztzoffset.__init__   s'     *:):;;;_W


r/   c                 R    t           | j                                         | j        ffS r+   )rG   rz   total_secondsr{   r|   s    r.   
__reduce__ztzoffset.__reduce__   s%    4<55777DDDr/   dtc                     | j         S r+   )rz   r|   r   s     r.   	utcoffsetztzoffset.utcoffset   s
    |r/   c                     | j         S r+   )r{   r   s     r.   tznameztzoffset.tzname   s
    zr/   c                     t           S r+   )ZEROr   s     r.   dstztzoffset.dst   s    r/   r+   )r8   r9   r:   floatr   rP   r}   r   r   r   r
   r   r   r   r   r,   r/   r.   rG   rG      s       % % %eD#I6F %RV % % % %EE$z"2E%*4E"EF E E E EE(D.1 i    x~. 3    eHdN+ 	      r/   rG   UTC	timestamp	tz_offsetc                     t          j        | t                    }	 |                    t	          |                    }|S # t
          $ r |cY S w xY w)zAConverts a timestamp + tz_offset into an aware datetime instance.)r
   fromtimestamprH   
astimezonerG   r\   )r   r   utc_dtlocal_dts       r.   from_timestampr      s]    #Is33F$$Xi%8%899   s   #A   AAstring_datec                 v   t          | t                    r| j        rt          t          |                                           }t          |                                           }t          |                     t                    
                                          |fS t          d|            	 |                     d          dk    r||                     d          dk    rc|                                 \  }}|                    d          r
|dd         }t          |          }|t!          t#          |                    fS d}| d	         d
v r!t#          | d	d                   }| dd         } t!          |          }g }d}d| v r+|                    d           |                     d          }n|                    d           |                    d           |                    d           |                    d           |                     d          }|dk    r|                     d          }|dk    sJ | |dz   d         }| d|         }	t'          j        |d          }
|D ]}	 t'          j        |	|          }t+          j        |j        |j        |j        |
j        |
j        |
j        |j        |j        |
j        f	          }t          |          |fc S # t          $ r Y w xY wt          d          # t@          $ r(}t          d|  dtC          |                      |d}~ww xY w)a  
    Parse the given date as one of the following

        * aware datetime instance
        * Git internal format: timestamp offset
        * RFC 2822: Thu, 07 Apr 2005 22:13:13 +0200.
        * ISO 8601 2005-04-07T22:13:13
            The T can be a space as well

    :return: Tuple(int(timestamp_UTC), int(offset)), both in seconds since epoch
    :raise ValueError: If the format could not be understood
    :note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY.
    z,string_date datetime object without tzinfo,  r    :@Nz+0000z-+rL   ,z%a, %d %b %Yz%Y-%m-%dz%Y.%m.%dz%m/%d/%Yz%d.%m.%YTz%H:%M:%Szno format matchedz!Unsupported date format or type: z, type=)"
isinstancer
   r   r   r   r   r;   r   r   rH   r   r\   countrfindsplit
startswithrE   rF   appendtimestrptimecalendartimegmtm_yeartm_montm_mdaytm_hourtm_mintm_sectm_wdaytm_ydaytm_isdst	Exceptiontype)r   r   rn   r   
offset_strtimestamp_intdate_formatssplitter	time_part	date_parttstructfmtdtstructutctimees                  r.   rA   rA      s    +x(( [ 	[Y(=(=(?(?@@I)1133444F{--c22<<>>??GGYKYYZZZEmS!!Q&&;+<+<S+A+AR+G+G$/$5$5$7$7!Iz##C(( *%abbM		NNM -Z0H0H"I"III J2$&&)+bcc*:;;
)#2#.":..F LHk!!##N333&,,S11 ##J///##J///##J///##J///&,,S11r>>*0055H b==== $HqLNN3I#IXI.I mIz::G#  #}Y<<H&o$,$O$,#O#N#N$,$,#,
 G w<<////!   H 0111 m m md[ddQUVaQbQbddeekllmsE   4BL 	D+L 5A/K'$L '
K41L 3K44L 
L8#L33L8z^.+? (.*) (\d+) ([+-]\d+).*$z
^.+? (.*)$linec                 D   d\  }}}t                               |           }|r|                                \  }}}n5t                              |           }|r|                    d          n| pd}t          j        |          t          |          t          |          fS )zParse out the actor (author or committer) info from a line like::

        author Tom Preston-Werner <tom@mojombo.com> 1191999972 -0700

    :return: [Actor, int_seconds_since_epoch, int_timezone_offset])r[   0r   r    r[   )	_re_actor_epochsearchgroups_re_only_actorgroupr   _from_stringr;   rE   )r   actorepochrn   ms        r.   rB   rB   3  s     (E5&t$$A 0 xxzzuff!!$''/


TZRu%%s5zz=3H3HIIr/   c                   :    e Zd ZdZdZdddeddfdZd	edefd
ZdS )rC   a  Class wireing all calls to the contained Process instance.

    Use this type to hide the underlying process to provide access only to a specified
    stream. The process is usually wrapped into an AutoInterrupt class to kill
    it if the instance goes out of scope.)_proc_streamprocessr&   stream_namerJ   Nc                 >    || _         t          ||          | _        d S r+   )r   getattrr   )r|   r   r   s      r.   r}   zProcessStreamAdapter.__init__S  s    
!(+!>!>r/   attrc                 ,    t          | j        |          S r+   )r   r   )r|   r   s     r.   __getattr__z ProcessStreamAdapter.__getattr__W  s    t|T***r/   )	r8   r9   r:   __doc__	__slots__rP   r}   r   r   r,   r/   r.   rC   rC   I  sp        - - %I? ?c ?d ? ? ? ?+ + + + + + + +r/   rC   c                      e Zd ZdZdZeededed          fd                        Z	edededefd            Z
	 dd
edededeed                  fdZedededefd            Zd d ddddd	fdeed def         egef         deed def         egef         dedededed
edeeed                  ee         f         fdZdS )r4   zSimple interface to perform depth-first or breadth-first traversals
    into one direction.
    Subclasses only need to implement one function.
    Instances of the Subclass must be hashable

    Defined subclasses = [Commit, Tree, SubModule]
    r,   r5   rJ   c                      t          d          )a@  
        Returns:
            Tuple of items connected to the given item.
            Must be implemented in subclass

        class Commit::     (cls, Commit) -> Tuple[Commit, ...]
        class Submodule::  (cls, Submodule) -> Iterablelist[Submodule]
        class Tree::       (cls, Tree) -> Tuple[Tree, ...]
        To be implemented in subclassNotImplementedError)clsr5   s     r.   _get_intermediate_itemsz#Traversable._get_intermediate_itemsh  s     ""ABBBr/   argskwargsc                 T    t          j        dt          d            | j        |i |S )r   zlist_traverse() method should only be called from subclasses.Calling from Traversable abstract class will raise NotImplementedError in 3.1.20Builtin sublclasses are 'Submodule', 'Tree' and 'Commitrq   
stacklevel)warningswarnDeprecationWarning_list_traverser|   r   r   s      r.   list_traversezTraversable.list_traversev  sE     	F 	
 	
 	
 	
 #t"D3F333r/   Fas_edge)r!   r'   r$   r"   c                     t          | t                    r| j        }nd}|s3t          |          }|                     | j        |d|i|           |S t           | j        |i |          }|S )a  
        :return: IterableList with the results of the traversal as produced by
            traverse()
            Commit -> IterableList['Commit']
            Submodule ->  IterableList['Submodule']
            Tree -> IterableList[Union['Submodule', 'Tree', 'Blob']]
        r[   r   )r   r   _id_attribute_r   extendtraverse)r|   r   r   r   idoutout_lists          r.   r   zTraversable._list_traverse  s     d,-- 	$BBB  		NZ[]N^N^CJJ}t}tFWFvFFGGGJ
 &2-$-2P2P2P%Q%QHOr/   c                 T    t          j        dt          d            | j        |i |S )r   ztraverse() method should only be called from subclasses.Calling from Traversable abstract class will raise NotImplementedError in 3.1.20Builtin sublclasses are 'Submodule', 'Tree' and 'Commitrq   r   )r   r   r   	_traverser   s      r.   r   zTraversable.traverse  sD     	F 	
 	
 	
 	
 t~t.v...r/   c                     dS NTr,   ids     r.   <lambda>zTraversable.<lambda>  s    dh r/   c                     dS NFr,   r   s     r.   r   zTraversable.<lambda>  s    `e r/   r   Tr    	predicater"   pruner2   branch_first
visit_onceignore_selfr3   c           
   #      K   	 t                      }t                      }	|	                    t          d d                     dt          t                   dddt
          dt          ddf
 fd	}
|	r|	                                \  }}|r|v r!|r|                               |r|f}n} |||          rN|o u }|s |||          r|V  |d
z   }|dk    r||k    rx |
|	||           |	dS dS )aF  :return: iterator yielding of items found when traversing self
        :param predicate: f(i,d) returns False if item i at depth d should not be included in the result

        :param prune:
            f(i,d) return True if the search should stop at item i at depth d.
            Item i will not be returned.

        :param depth:
            define at which level the iteration should not go deeper
            if -1, there is no limit
            if 0, you would effectively only get self, the root of the iteration
            i.e. if 1, you would only get the first level of predecessors/successors

        :param branch_first:
            if True, items will be returned branch first, otherwise depth first

        :param visit_once:
            if True, items will only be returned once, although they might be encountered
            several times. Loops are prevented that way.

        :param ignore_self:
            if True, self will be ignored and automatically pruned from
            the result. Otherwise it will be the first item to be returned.
            If as_edge is True, the source of the first edge is None

        :param as_edge:
            if True, return a pair of items, first being the source, second the
            destination, i.e. tuple(src, dest) with the edge spanning from
            source to destinationr   Nstacksrc_itemr4   r   r2   rJ   c                                                   sd S |r$|                     fdD                        d S fdt          t                    dz
  dd          D             }|                     |           d S )Nc              3   :   K   | ]}t          |          V  d S r+   r1   ).0r   r2   r  s     r.   	<genexpr>z<Traversable._traverse.<locals>.addToStack.<locals>.<genexpr>  s/       M MAE1h!?!? M M M M M Mr/   c              3   F   K   | ]}t          |                   V  d S r+   r  )r  r   r2   lstr  s     r.   r  z<Traversable._traverse.<locals>.addToStack.<locals>.<genexpr>  s3      dd1:eSVX>>ddddddr/   r    r   )r   
extendleftrangers   r   )r   r  r   r2   reviterr  r5   r|   s    ` ` @r.   
addToStackz)Traversable._traverse.<locals>.addToStack  s     ..t44C t &   M M M M M M M MMMMMMddddddcRUhhYZl\^`bHcHcdddW%%%%%r/   r    r   )	setr   r   r1   r   boolr;   popadd)r|   r   r   r2   r   r   r   r   visitedr   r  r   r7   rvalskipStartItemndr5   s   `               @r.   r   zTraversable._traverse  s     P		L %%#(77Z4..///	&$	&#	& 	& 		&
 	& 	& 	& 	& 	& 	& 	&"  	6 99;;LAtS dgoo "D!!!  T{uT1~~ ':TT\M  YYtQ%7%7 


 QBrzzb5jjJudL"5557  	6 	6 	6 	6 	6r/   N)F)r8   r9   r:   r   r   classmethodr   r   r   r   r   r  r   r   r   r   r   TraversedTupr;   r   r   r,   r/   r.   r4   r4   [  s         I
C3 
C8M3J 
C 
C 
C ^ [
C 	43 	4# 	4# 	4 	4 	4 ^	4 $ ,/;>	eAB	C   : 	/c 	/S 	/S 	/ 	/ 	/ ^	/ XiWhSeSe!c6 c6U=&,#FGMtSTc6 }flBCSI4OPc6 	c6
 c6 c6 c6 c6 
x345x7MM	Nc6 c6 c6 c6 c6 c6r/   c                   &    e Zd ZdZdZd	dZd	dZdS )
SerializablezPDefines methods to serialize and deserialize objects from and into a data streamr,   streamr   rJ   c                      t          d          )zSerialize the data of this object into the given data stream
        :note: a serialized object would ``_deserialize`` into the same object
        :param stream: a file-like object
        :return: selfr   r   r|   r  s     r.   
_serializezSerializable._serialize  s    
 ""ABBBr/   c                      t          d          )zDeserialize all information regarding this object from the stream
        :param stream: a file-like object
        :return: selfr   r   r  s     r.   _deserializezSerializable._deserialize"  s     ""ABBBr/   N)r  r   rJ   r  )r8   r9   r:   r   r   r  r  r,   r/   r.   r  r    sT         [ZIC C C CC C C C C Cr/   r  c                   
    e Zd ZdZeeedf         ef         Zdededede	e         f fdZ
ededee         fd            Zeded	eeeeeedf         ef         f         egef         d
eeeeeedf         ef         f         egef         dedededed         ded         dee         fd            Zeded	eeeeeedf         ef         f         egef         d
eeeeeedf         ef         f         egef         dedededed         ded         deeeedf         ef                  fd            Zeded	eeeef         egef         d
eeeef         egef         dedededed         ded         deeeef                  fd            Zd d dddddfded	eeeef         egef         d
eeeef         egef         dedededededeee         eeeef                  ee         f         f fdZ xZS )r>   r,   Nr|   r   r   rJ   c                 D     t          t          |           j        |i |S r+   )superr>   r   )r|   r   r   	__class__s      r.   r   z$TraversableIterableObj.list_traverse.  s&    Au+T22A4R6RRRr/   c                     d S r+   r,   r   s    r.   r   zTraversableIterableObj.traverse1  s    r/   r   r   r2   r   r   r   Tr   Fc                     d S r+   r,   r|   r   r   r2   r   r   r   r   s           r.   r   zTraversableIterableObj.traverse5  	     	r/   c                     d S r+   r,   r%  s           r.   r   zTraversableIterableObj.traverseB  r&  r/   c                     d S r+   r,   r%  s           r.   r   zTraversableIterableObj.traverseO  r&  r/   c                     dS r   r,   r   s     r.   r   zTraversableIterableObj.<lambda>^  s    UY r/   c                     dS r   r,   r   s     r.   r   zTraversableIterableObj.<lambda>_  s    QV r/   r   r    c                    	 t          t          t          t                   t          t          t          dt          f         t          f                  f         t          t          |                               |||||||                    S )z3For documentation, see util.Traversable._traverse()N)r   r   r   r=   r   r!  r>   r   )	r|   r   r   r2   r   r   r   r   r"  s	           r.   r   zTraversableIterableObj.traverse\  st    	  (7#XeE$-4H'4Q.R%SST($//995%z;PW 
 
 	
r/   )r8   r9   r:   r   r   r   r=   TIobj_tupler   r   r   r   r   r   r   r;   r  r   __classcell__)r"  s   @r.   r>   r>   )  s6       Igtm,g56KSG SC S3 S<PWCX S S S S S S w 8G#4    X 

U7E%2F2O,P#PQSVWY]]^
 weGTM.BG.K(LLMsSUYYZ
 	

 
 
 T]
 
 
'	
 
 
 X
 

U7E%2F2O,P#PQSVWY]]^
 weGTM.BG.K(LLMsSUYYZ
 	

 
 
 U^
 
 
%gtm,g56	7
 
 
 X
 

U7K#78#>DE
 w34c:D@A
 	

 
 
 T]
 
 
%()	*
 
 
 X
 IZHYDVDV!!
 !
!
U7K#78#>DE!
 w34c:D@A!
 	!

 !
 !
 !
 !
 
x (5'1A+B"CXkEZZ	[!
 !
 !
 !
 !
 !
 !
 !
 !
 !
r/   )Sr   abcr   r   r   git.utilr   r   r   recollectionsr   stringr	   r   r   r
   r   r   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   	git.typesr   r   r   ior   r   rW   r!   rY   r"   rX   r#   rZ   r$   r%   
subprocessr&   submodule.baser'   r(   r)   r1   r=   r  __all__r   bytesrP   r;   rT   r@   rE   r   rD   rF   rG   rH   r   rA   compiler   r   rB   objectrC   r4   r  r>   r,   r/   r.   <module>r<     sk   + * $ # # # # # # #  5 5 5 5 5 5 5 5 5 5 				               0 0 0 0 0 0 0 0 0 0                               " 4 3 3 3 3 3 3 3 3 3 $$$$$$$$,,,,,,,,      ))))))555555555 H  $ $ $ $ $ $ $ $ ')#;
<
<
<	%#
$m
34 y||
U5#:. 3     ^^
4>4,d6lDLHI^ ^ ^ ^<2 2 2 2 2 27E 7c 7 7 7 7         v   $ hq%e  (    \mE#x-0 \mU38_ \m \m \m \mB "*<==M**Js JuUC_'= J J J J,+ + + + +6 + + +$ r6 r6 r6 r6 r6( r6 r6 r6l C C C C C8 C C C,T
 T
 T
 T
 T
[+ T
 T
 T
 T
 T
r/   