
    ,OfD                        d dl Zd dlZd dlmZmZ d dlmZ d dlmZ d dl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 ddlmZ dd	lmZmZ e	rdd
lmZ  ej6                  d      Z ej6                  d      Z ej6                  dd      Z ej6                  dd      Z G d dee         Z de!defdZ"de!defdZ# G d d      Z$ e$       Z%eee$f   Z&deee$f   dee   fdZ'deee$f   dee$   fdZ(de
deeeedf   f   de)fd Z*de
deeeedf   f   de)fd!Z+ G d" d#e e         Z, G d$ d%e       Z- G d& d      Z. G d' d(e.      Z/ G d) d*e.      Z0y)+    N)datetimetimezone)Decimal)
itemgetter)	TYPE_CHECKINGAnyCallableDictListOptionalTupleTypeUnion)Protocol	TypeGuard   )Consts)BadAttributeExceptionIncompletableObject)	RequesterTKT_coT)	covariantT_ghGithubObject)boundc                   "    e Zd Zedefd       Zy)	Attributereturnc                     t         NNotImplementedErrorselfs    3lib/python3.12/site-packages/github/GithubObject.pyvaluezAttribute.valueH   s    !!    N)__name__
__module____qualname__propertyr   r(    r)   r'   r   r   G   s    "t " "r)   r   r(   r    c                     t         j                  j                  |       }|j                   |j	                  t
        j                        S |S )z_
    Convert an HTTP date to a datetime object.

    Raises ValueError for invalid dates.

    )tzinfo)emailutilsparsedate_to_datetimer0   replacer   utc)r(   dts     r'   _datetime_from_http_dater7   M   s<     
	*	*5	1B	yyzzz..Ir)   c                 ^    | j                  d      r| dd dz   } t        j                  |       S )zp
    Convert an GitHub API timestamps to a datetime object.

    Raises ValueError for invalid timestamps.

    ZNz+00:00)endswithr   fromisoformatr(   s    r'   _datetime_from_github_isoformatr>   \   s1     ~~ccr
X%!!%((r)   c                   \    e Zd ZdefdZedefd       Zede	eef   de	eef   fd       Z
y)_NotSetTyper    c                      y)NNotSetr.   r%   s    r'   __repr__z_NotSetType.__repr__m   s    r)   c                      y r"   r.   r%   s    r'   r(   z_NotSetType.valuep   s    r)   datac                 x    | j                         D ci c]  \  }}t        |t              r|| c}}S c c}}w r"   )items
isinstancer@   )rE   keyr(   s      r'   remove_unset_itemsz_NotSetType.remove_unset_itemst   s.    -1ZZ\`zsEES^A_U
```s   66N)r*   r+   r,   strrC   r-   r   r(   staticmethodr
   rJ   r.   r)   r'   r@   r@   l   s_    #  s   ac3h aDcN a ar)   r@   vc                 $    t        | t               S r"   rH   r@   rM   s    r'   
is_definedrQ   ~   s    ![)))r)   c                 "    t        | t              S r"   rO   rP   s    r'   is_undefinedrS      s    a%%r)   type.c                 >    t        | t              xs t        | |      S r"   rO   rM   rT   s     r'   is_optionalrW      s    a%<At)<<r)   c                 t    t        | t              xs& t        | t              xr t        fd| D              S )Nc              3   6   K   | ]  }t        |        y wr"   rH   .0elementrT   s     r'   	<genexpr>z#is_optional_list.<locals>.<genexpr>   s     DpcjZPWY]E^Dp   )rH   r@   listallrV   s    `r'   is_optional_listrb      s-    a%pAt)<)pDpnoDpAppr)   c                   .    e Zd ZdefdZedefd       Zy)_ValuedAttributer(   c                     || _         y r"   _valuer&   r(   s     r'   __init__z_ValuedAttribute.__init__   s	    r)   r    c                     | j                   S r"   rf   r%   s    r'   r(   z_ValuedAttribute.value   s    {{r)   N)r*   r+   r,   r   ri   r-   r(   r.   r)   r'   rd   rd      s)    a  q  r)   rd   c                   >    e Zd Zddededee   fdZedefd       Zy)	_BadAttributeNr(   expectedType	exceptionc                 .    || _         || _        || _        y r"   )_BadAttribute__value_BadAttribute__expectedType_BadAttribute__exception)r&   r(   rm   rn   s       r'   ri   z_BadAttribute.__init__   s    *$r)   r    c                 X    t        | j                  | j                  | j                        r"   )r   rp   rq   rr   r%   s    r'   r(   z_BadAttribute.value   s!    #DLL$2E2EtGWGWXXr)   r"   )	r*   r+   r,   r   r   	Exceptionri   r-   r(   r.   r)   r'   rl   rl      s?    %c % %)AT %
 Ys Y Yr)   rl   c                      e Zd ZU dZ	 dZee   ed<   ede	ddfd       Z
dd	d
eeeeef   f   dede	fdZd
eeeeef   f   deddfdZedeeef   fd       Zedeeeeef   f   fd       Zededefd       Zededee   dee   fd       Zededee   dee   fd       Zededee   deegef   dee   fd       Zedeeeef      dee   fd       Zedeeeef      dee   fd       Z edee!   dee!   fd       Z"edee#   dee#   fd       Z$edee	   dee	   fd       Z%edeeef   deeeef      fd       Z&ededee'   fd       Z(edee   dee'   fd        Z)edee   dee'   fd!       Z*d"ee+   dedee+   fd#Z,edee-e-e      e-e   e-eeef      f   defd$       Z.ede-e   defd%       Z/ede-eeeee-eeeee-e   f   f      f   f      defd&       Z0ede-e-e      defd'       Z1d"ee+   dedee-e+      fd(Z2d"ee+   deeeeeeeeedf   f   eeeeef   f   f   f   deeee+f      fd)Z3edee   fd*       Z4edee   fd+       Z5edee'   fd,       Z6d-eeef   defd.Z7d2d/Z8deddfd0Z9d2d1Z:y)3r   zN
    Base class for all classes representing objects returned by the API.
    F_urlflagr    Nc                     || _         y r"   )CHECK_AFTER_INIT_FLAG)clsrw   s     r'   setCheckAfterInitFlagz"GithubObject.setCheckAfterInitFlag   s
    $(!r)   	requesterr   headers
attributes	completedc                     || _         | j                          | j                  ||       | j                  r|j	                  |        y y r"   )
_requester_initAttributes_storeAndUseAttributesry   check_me)r&   r|   r}   r~   r   s        r'   ri   zGithubObject.__init__   sE     $##GZ8 %%t$ &r)   c                 B    || _         || _        | j                  |       y r"   )_headers_rawData_useAttributes)r&   r}   r~   s      r'   r   z#GithubObject._storeAndUseAttributes   s       "J'r)   c                 :    | j                          | j                  S z
        :type: dict
        )_completeIfNeededr   r%   s    r'   raw_datazGithubObject.raw_data       
 	 }}r)   c                 :    | j                          | j                  S r   )r   r   r%   s    r'   raw_headerszGithubObject.raw_headers   r   r)   urlc                 H    dj                  | j                  d      d d       S )N/r:   )joinsplit)r   s    r'   
_parentUrlzGithubObject._parentUrl   s     xx		#s+,,r)   r(   rT   c                 L    | t        | |      rt        |       S t        | |      S r"   )rH   rd   rl   r(   rT   s     r'   __makeSimpleAttributez"GithubObject.__makeSimpleAttribute   s(    =Jud3#E** --r)   c                 |    t        | t              rt        fd| D              rt        |       S t	        | g      S )Nc              3   6   K   | ]  }t        |        y wr"   rZ   r[   s     r'   r^   z9GithubObject.__makeSimpleListAttribute.<locals>.<genexpr>   s     *Z:gt+D*Zr_   )rH   r`   ra   rd   rl   r   s    `r'   __makeSimpleListAttributez&GithubObject.__makeSimpleListAttribute   s5    eT"s*ZTY*Z'Z#E** //r)   	transformc                     | t        d       S t        | |      r	 t         ||             S t        | |      S # t        $ r}t        | ||      cY d }~S d }~ww xY wr"   )rd   rH   rt   rl   )r(   rT   r   es       r'   __makeTransformedAttributez'GithubObject.__makeTransformedAttribute   sa    =#D))t$5'	%(899 !--  5$UD!445s   8 	AAAAc                 6    t         j                  | t              S r"   )r   "_GithubObject__makeSimpleAttributerK   r=   s    r'   _makeStringAttributez!GithubObject._makeStringAttribute       11%==r)   c                 6    t         j                  | t              S r"   )r   r   intr=   s    r'   _makeIntAttributezGithubObject._makeIntAttribute   r   r)   c                 6    t         j                  | t              S r"   )r   r   r   r=   s    r'   _makeDecimalAttributez"GithubObject._makeDecimalAttribute   s    11%AAr)   c                 6    t         j                  | t              S r"   )r   r   floatr=   s    r'   _makeFloatAttributez GithubObject._makeFloatAttribute  s    11%??r)   c                 6    t         j                  | t              S r"   )r   r   boolr=   s    r'   _makeBoolAttributezGithubObject._makeBoolAttribute      11%>>r)   c                 6    t         j                  | t              S r"   )r   r   dictr=   s    r'   _makeDictAttributezGithubObject._makeDictAttribute  r   r)   c                 :    t         j                  | t        d       S )Nc                 L    t        j                  | t        j                        S )N)tz)r   fromtimestampr   r5   )ts    r'   <lambda>z6GithubObject._makeTimestampAttribute.<locals>.<lambda>  s    h,,Q8<<@ r)   )r   '_GithubObject__makeTransformedAttributer   r=   s    r'   _makeTimestampAttributez$GithubObject._makeTimestampAttribute  s    66@
 	
r)   c                 @    t         j                  | t        t              S r"   )r   r   rK   r>   r=   s    r'   _makeDatetimeAttributez#GithubObject._makeDatetimeAttribute  s    66ucCbccr)   c                 @    t         j                  | t        t              S r"   )r   r   rK   r7   r=   s    r'   _makeHttpDatetimeAttributez'GithubObject._makeHttpDatetimeAttribute  s    66ucC[\\r)   klassc                 D     t         j                  |t         fd      S )Nc                 D     j                   j                  | d      S )NFr   )r   r   )r(   r   r&   s    r'   r   z2GithubObject._makeClassAttribute.<locals>.<lambda>$  s    %QVW r)   )r   r   r   )r&   r   r(   s   `` r'   _makeClassAttributez GithubObject._makeClassAttribute   s    66W
 	
r)   c                 6    t         j                  | t              S r"   )r   &_GithubObject__makeSimpleListAttributerK   r=   s    r'   _makeListOfStringsAttributez(GithubObject._makeListOfStringsAttribute'      55eSAAr)   c                 6    t         j                  | t              S r"   )r   r   r   r=   s    r'   _makeListOfIntsAttributez%GithubObject._makeListOfIntsAttribute+  r   r)   c                 6    t         j                  | t              S r"   )r   r   r   r=   s    r'   _makeListOfDictsAttributez&GithubObject._makeListOfDictsAttribute/       55eTBBr)   c                 6    t         j                  | t              S r"   )r   r   r`   r=   s    r'   !_makeListOfListOfStringsAttributez.GithubObject._makeListOfListOfStringsAttribute5  r   r)   c                     t        |t              rIt        d |D              r7t        |D cg c]"  } || j                  | j
                  |d      $ c}      S t        |t        g      S c c}w )Nc              3   <   K   | ]  }t        |t                y wr"   )rH   r   )r\   r]   s     r'   r^   z;GithubObject._makeListOfClassesAttribute.<locals>.<genexpr><  s     *Z:gt+D*Zs   Fr   )rH   r`   ra   rd   r   r   rl   r   )r&   r   r(   r]   s       r'   _makeListOfClassesAttributez(GithubObject._makeListOfClassesAttribute;  s`    eT"s*ZTY*Z'Z#`efU\tw%Pf  !// gs   'A+c                 0   t        |t              rkt        d |j                         D              rKt	        |j                         D ci c]&  \  }}| || j
                  | j                  |d      ( c}}      S t        |t        t        i      S c c}}w )Nc              3   f   K   | ])  \  }}t        |t              xr t        |t               + y wr"   )rH   rK   r   )r\   rI   r]   s      r'   r^   zDGithubObject._makeDictOfStringsToClassesAttribute.<locals>.<genexpr>K  s/      +
CO3JsC >Z%>>+
s   /1Fr   )	rH   r   ra   rG   rd   r   r   rl   rK   )r&   r   r(   rI   r]   s        r'   $_makeDictOfStringsToClassesAttributez1GithubObject._makeDictOfStringsToClassesAttributeC  s     eT"s +
SXS^S^S`+
 (
 $jojujujwxZfZ]_feDOOT]]GuUUx  !d44 ys   	+B
c                 T    | j                   j                  t        j                        S z
        :type: str
        )r   getr   RES_ETAGr%   s    r'   etagzGithubObject.etagT  s    
 }}  11r)   c                 T    | j                   j                  t        j                        S r   )r   r   r   RES_LAST_MODIFIEDr%   s    r'   last_modifiedzGithubObject.last_modified[  s    
 }}  !9!9::r)   c                 L    | j                  | j                        j                  S )z!
        :type: datetime
        )r   r   r(   r%   s    r'   last_modified_datetimez#GithubObject.last_modified_datetimeb  s!    
 ..t/A/ABHHHr)   paramsc           
          dt         t        t        f   dt        j                  t        ddf   fd}dj                  | j                  j                  dj                  t         ||                        S )zC
        Converts the object to a nicely printable string.
        r   r    Nc              3      K   t        | j                               }t        |t        d      d      D ]E  \  }}t	        |t
              r|j                  d      }t	        |t              rd| d}| d|  G y w)Nr   T)rI   reversezutf-8"=)r`   rG   sortedr   rH   bytesdecoderK   )r   rG   krM   s       r'   format_paramsz/GithubObject.get__repr__.<locals>.format_paramsn  su     (Eu*Q-F !1a')Aa%A3aA1QCj !s   A:A<z{class_name}({params})z, )
class_namer   )
r
   rK   r   typing	Generatorformat	__class__r*   r   r`   )r&   r   r   s      r'   get__repr__zGithubObject.get__repr__i  sl    
	!$sCx. 	!V5E5Ec4QUo5V 	! (..~~..99T-"789 / 
 	
r)   c                     t        d      )Nz$BUG: Not Implemented _initAttributesr#   r%   s    r'   r   zGithubObject._initAttributes|  s    !"HIIr)   c                     t        d      )Nz#BUG: Not Implemented _useAttributesr#   )r&   r~   s     r'   r   zGithubObject._useAttributes  s    !"GHHr)   c                     t        d      )Nz&BUG: Not Implemented _completeIfNeededr#   r%   s    r'   r   zGithubObject._completeIfNeeded  s    !"JKKr)   r    N);r*   r+   r,   __doc__ry   r   rK   __annotations__classmethodr   r{   r
   r   r   r   ri   r   r-   r   r   rL   r   r   r   r   r`   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r.   r)   r'   r   r      s    "
C.) )$ ) )%% c5c?*+% 	%
 % (d3c3h3G.H (VY (^b ( $sCx.   T#uS#X"67   - - - - .S .Q .IaL . . 0 0T!W 01 0 0 	.! 	.47 	.xQRPSUVPVGW 	.\efg\h 	. 	. >HU38_$= >)C. > > >%S/!: >y~ > > BXg%6 B9W;M B B @8E? @y7G @ @ ?(4. ?Yt_ ? ? ?$sCx. ?YtCH~5N ? ? 
s 
y/B 
 
 dhsm d	(8K d d ](3- ]Ih<O ] ]
d 
C 
IdO 
 B5d3i$s)TRWX[]`X`RaMb1b+c Bhq B B BS	 Bi B B CDeCd3c49n8M3M.N)O$OPPQRC	C C
 CDIC	C C
0d 0C 0IVZ[_V`La 05Dz5 #tCsC~!667c5c?>R9SSTV
5 
4T	?	#5" 2hsm 2 2 ;x} ; ; I(: I I
$sCx. 
S 
&JI I ILr)   c                       e Zd ZddZy)NonCompletableGithubObjectNc                      y r"   r.   r%   s    r'   r   z,NonCompletableGithubObject._completeIfNeeded  s    r)   r   )r*   r+   r,   r   r.   r)   r'   r   r     s    r)   r   c                        e Zd Zdddeeeeef   f   deeef   def fdZ	dedefd	Z
defd
ZdedefdZdeddfdZddZddZddeeeef      defdZ xZS )CompletableGithubObjectr|   r   r}   r~   r   c                 8    t         |   ||||       || _        y r"   )superri   #_CompletableGithubObject__completed)r&   r|   r}   r~   r   r   s        r'   ri   z CompletableGithubObject.__init__  s      	GZC$r)   otherr    c                     |j                   | j                   u xr- |j                  j                  | j                  j                  k(  S r"   )r   rv   r(   r&   r   s     r'   __eq__zCompletableGithubObject.__eq__  s1    $..0XUZZ5E5E5XXr)   c                 @    t        | j                  j                        S r"   )hashrv   r(   r%   s    r'   __hash__z CompletableGithubObject.__hash__  s    DIIOO$$r)   c                     | |k(   S r"   r.   r  s     r'   __ne__zCompletableGithubObject.__ne__  s    5=  r)   r(   Nc                 F    t        |t              r| j                          y y r"   )rH   r@   r   rh   s     r'   _completeIfNotSetz)CompletableGithubObject._completeIfNotSet  s    e[)""$ *r)   c                 >    | j                   s| j                          y y r"   )r   "_CompletableGithubObject__completer%   s    r'   r   z)CompletableGithubObject._completeIfNeeded  s    OO  r)   c                     | j                   j                  t        dd      | j                  j	                  d| j                   j                        \  }}| j                  ||       d| _        y )Ni  zReturned object contains no URL)messageGETT)rv   r(   r   r   requestJsonAndCheckr   r   )r&   r}   rE   s      r'   
__completez"CompletableGithubObject.__complete  sX    99??"%c3TUU;;E499??S##GT2r)   additional_headersc                    t               }| j                  | j                  |t        j                  <   | j                  | j                  |t        j
                  <   ||j                  |       | j                  j                  d| j                  j                  |      \  }}}|dk(  ry| j                  j                  |||      \  }}| j                  ||       d| _        y)z
        Check and update the object with conditional request :rtype: Boolean value indicating whether the object is
        changed.
        r  )r}   i0  FT)r   r   r   REQ_IF_NONE_MATCHr   REQ_IF_MODIFIED_SINCEupdater   requestJsonrv   r(   _Requester__checkr   r   )r&   r  conditionalRequestHeaderstatusresponseHeadersoutputr}   rE   s           r'   r  zCompletableGithubObject.update  s    
 $(6 99 AE$V%=%=>)EIEWEW$V%A%AB)$++,>?*.//*E*E499??,D +F +
' S= OO==foW]^MGT''6#Dr)   r   r"   )r*   r+   r,   r
   rK   r   r   r   r   ri   r  r  r  r   r	  r   r  r   r  __classcell__)r   s   @r'   r   r     s    %% c5c?*+% cN	%
 %YC YD Y%# %!C !D !%y %T % $sCx.)A T r)   r   )1email.utilsr1   r   r   r   decimalr   operatorr   r   r   r	   r
   r   r   r   r   r   typing_extensionsr   r    r   GithubExceptionr   r   r   TypeVarr   r   r   r   r   rK   r7   r>   r@   rB   OptrQ   rS   r   rW   rb   rd   rl   r   r   r   r.   r)   r'   <module>r%     s  d   '   Y Y Y 1  G$FNN3FNN3v~~f-v~~fN3" "C H )3 )8 ) 
a 
a 
A{N*%;' *IaL *&E![.) &i.D &=3 =eD%c	*:$:; = =q q5uT3Y/?)?#@ qT qy| YI Y_L _LD 
9l 9r)   