
    _OgU+                         S r SSKrSSKrSSKrSSKrSSKr	SSK
Jr  SSK
Jr  \R                  (       a  SSK
Jr  \R                  " \5      r\R$                  " S5      r " S S	5      rg)
z9This module provides the basic models used in github3.py.    N   )
exceptions)session)structsTc                      \ rS rSr% SrSrSr\R                  S    \	S'   S\
R                  4S jrS rS	 rS
 rS r\S 5       rS r\S 5       r\S 5       rS rS rS rS r\S 5       rS rS1S jrS rS rS r S r!S r"S2S jr#S r$S r%\&S 5       r'\S  5       r(\'RR                  S! 5       r'    S3S"\*S#\+S$\RX                  \-   S%\R                  \R\                  \+\R                  \+   4      S&\R                  \+   S'\R                  \R\                  \+\+4      S(\R                  \+   S)S*4S+ jjr/\&S, 5       r0S4S-\1S)S 4S. jjr2S/ r3S0r4g)5
GitHubCore   zThe base object for all objects that require a session.

The :class:`GitHubCore <GitHubCore>` object provides some
basic attributes and methods to other sub-classes that are very useful to
have.
coreN_refresh_tor   c                 F   [        USU5      U l        SU l        UbE  UR                  SS5      U l        UR                  SS5      U l        UR                  SS5      U l        Xl         U R                  U5        g! [         a  n[        R                  " X5      eSnAff = f)z`Initialize our basic object.

Pretty much every object will pass in decoded JSON and a Session.
r   zhttps://api.github.comNETagLast-Modifiedurl)getattrr   _github_urlpopetaglast_modifiedget_uniq
_json_data_update_attributesKeyErrorr   IncompleteResponse)selfjsonr   kerrs       S/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/github3/models.py__init__GitHubCore.__init__!   s     w	7; 4.DI!%/4!@D%.DJ	<##D) 	<//;;	<s   )A; ;
B BB c                     g N )r   r   s     r   r   GitHubCore._update_attributes8   s        c                 r    [         R                  U S5      nX;  a  [        U5      eX!   n[        XU5        U$ )zProxy access to stored JSON.r   )object__getattribute__AttributeErrorsetattr)r   	attributer   values       r   __getattr__GitHubCore.__getattr__;   s<    ,,T<@
& ++%'r&   c                     U R                   $ )zReturn the attributes for this object as a dictionary.

This is equivalent to calling::

    json.loads(obj.as_json())

:returns: this object's attributes serialized to a dictionary
:rtype: dict
)r   r   s    r   as_dictGitHubCore.as_dictD   s     r&   c                 B    [         R                  " U R                  5      $ )zReturn the json data for this object.

This is equivalent to calling::

    json.dumps(obj.as_dict())

:returns: this object's attributes as a JSON string
:rtype: str
)jsonlibdumpsr   r1   s    r   as_jsonGitHubCore.as_jsonP   s     }}T__--r&   c                 P    U(       a  [         R                  R                  U5      $ g)a%  Convert an ISO 8601 formatted string to a datetime object.

We assume that the ISO 8601 formatted string is in UTC and we create
the datetime object so that it is timezone-aware.

:param str time_str: ISO 8601 formatted string
:returns: timezone-aware datetime object
:rtype: datetime or None
N)dateutilparserparse)clstime_strs     r   	_strptimeGitHubCore._strptime\   s     ??((22r&   c                     U R                  5       n[        R                  R                  (       a  UR	                  S5      $ U$ )Nzutf-8)_reprrequestscompatis_py2encode)r   repr_strings     r   __repr__GitHubCore.__repr__k   s1    jjl??!!%%g..r&   c                     U " X5      $ )z;Return an instance of this class formed from ``json_dict``.r$   )r=   	json_dictr   s      r   	from_dictGitHubCore.from_dictq   s     9&&r&   c                 <    U " [         R                  " U5      U5      $ )z6Return an instance of this class formed from ``json``.)r5   loads)r=   r   r   s      r   	from_jsonGitHubCore.from_jsonv   s     7==&00r&   c                 4    U R                   UR                   :H  $ r#   r   r   others     r   __eq__GitHubCore.__eq__{       zzU[[((r&   c                 4    U R                   UR                   :g  $ r#   rS   rT   s     r   __ne__GitHubCore.__ne__~   rX   r&   c                 ,    [        U R                  5      $ r#   )hashr   r1   s    r   __hash__GitHubCore.__hash__   s    DJJr&   c                 "    S[        U 5      S S3$ )Nz<github3-core at 0xx>)idr1   s    r   rB   GitHubCore._repr   s    $RXaL22r&   c                 f    U (       d  g [        U R                  5       5       H  u  pUb  M
  X	 M     g r#   )listitems)datakvs      r   _remove_noneGitHubCore._remove_none   s)    &DAyG 'r&   c                     Ub,  [        U[        5      (       d  [        R                  " SU5      eU(       d  g U" X 5      $ )Nz6GitHub's API returned a body that could not be handled)
isinstancedictr   UnprocessableResponseBody)r   instance_classr   s      r   _instance_or_nullGitHubCore._instance_or_null   s?    JtT$:$:66H$  d))r&   c                 x   S nUc  g UR                   nXR:w  a:  US:  a  [        R                  " U5      eUS:X  a  g [        R	                  SUU5         UR                  5       nUR                  nU(       a  UR                  S5      (       d  UR                  S5      (       aS  [        U[        5      (       a>  UR                  R                  SS5      US'   UR                  R                  SS5      US'   [        R                  SUc  S5        U$ S5        U$ ! [         a    [        R                  " U5      ef = f)	N  i0  z"Expected status_code %d but got %dr   r    zJSON was %sreturnedznot )status_coder   	error_forLOGwarningr   
ValueErrorUnexpectedResponseheadersr   rn   ro   info)r   responseexpected_status_codeinclude_cache_inforetactual_status_coder}   s          r   _jsonGitHubCore._json   s'   %115!S( **844!S(KK4$"	:--/C ""_--V1D1D3%%#+#3#3#7#7#LC "**..vr:CK&#+F
 DFF
  	://99	:s   D !D9c                 p    Ub3  UR                   nXB:X  a  gXC:w  a  US:  a  [        R                  " U5      eg)NTru   F)rw   r   rx   )r   r   	true_code
false_coderw   s        r   _booleanGitHubCore._boolean   s=    "..K'([C-? **844r&   c                 Z    [        U R                  U5      nU" U0 UD6$ ! [        R                  R                  [        R                  R
                  4 a  n[        R                  " U5      eS nAf[        R                  R                   a  n[        R                  " U5      eS nAff = fr#   )r   r   rC   r   ConnectionErrorTimeoutRequestExceptionTransportError)r   methodargskwargsrequest_methodexcs         r   _requestGitHubCore._request   s    		1$T\\6:N!42622//''
 	2 ,,S11""33 	1++C00	1s!     8B*A..!B*B%%B*c                 V    [         R                  SX5        U R                  " SU40 UD6$ )NzDELETE %s with %sdeletery   debugr   r   r   r   s      r   _deleteGitHubCore._delete   s'    		%s3}}Xs5f55r&   c                 V    [         R                  SX5        U R                  " SU40 UD6$ )NzGET %s with %sr   r   r   s      r   _getGitHubCore._get   '    		"C0}}UC2622r&   c                 V    [         R                  SX5        U R                  " SU40 UD6$ )NzPATCH %s with %spatchr   r   s      r   _patchGitHubCore._patch   s'    		$c2}}Wc4V44r&   c                     U(       a  Ub  [         R                  " U5      OUn[        R                  SXU5        U R                  " SX40 UD6$ )NzPOST %s with %s, %spost)r5   r6   ry   r   r   )r   r   rh   r   r   s        r   _postGitHubCore._post   sA    *.*:7==&D		'F;}}VS9&99r&   c                 V    [         R                  SX5        U R                  " SU40 UD6$ )NzPUT %s with %sputr   r   s      r   _putGitHubCore._put   r   r&   c                 :    U R                   R                  " U0 UD6$ )z!Build a new API url from scratch.)r   	build_url)r   r   r   s      r   
_build_urlGitHubCore._build_url   s    ||%%t6v66r&   c                     SR                  U R                  5      nU R                  R                  (       a  USU R                  R                   3-  nU$ )Nz{0.scheme}://{0.netloc}{0.path}?)format_uriquery)r   r-   s     r   _apiGitHubCore._api   s@    188C99??q)**Er&   c                 @    [         R                  R                  U 5      $ r#   )rC   rD   urlparse)uris    r   
_uri_parseGitHubCore._uri_parse   s    '',,r&   c                 J    U(       a  U R                  U5      U l        Xl        g r#   )r   r   r   )r   r   s     r   r   r      s    ,DIr&   countr   r=   paramsr   r}   list_keyreturnzstructs.GitHubIterator[T]c           
      $    SSK Jn  U" XX0XEXg5      $ )a&  Generic iterator for this project.

:param int count: How many items to return.
:param int url: First URL to start with
:param class cls: cls to return an object of
:param params dict: (optional) Parameters for the request
:param str etag: (optional), ETag from the last call
:param dict headers: (optional) HTTP Headers for the request
:param str list_key: (optional) Key for extracting the list of items
    from a dict response
:returns: A lazy iterator over the pagianted resource
:rtype: :class:`GitHubIterator <github3.structs.GitHubIterator>`
r   )GitHubIterator)r   r   )	r   r   r   r=   r   r   r}   r   r   s	            r   _iterGitHubCore._iter   s    . 	,6
 	
r&   c                     U R                  U R                  U R                  S5      5      S5      nUR                  S0 5      R                  U R                  0 5      nUR                  SS5      U l        U R
                  $ )zENumber of requests before GitHub imposes a ratelimit.

:returns: int

rate_limit   	resources	remainingr   )r   r   r   r   _ratelimit_resource
_remaining)r   r   r   s      r   ratelimit_remainingGitHubCore.ratelimit_remaining  se     zz$))DOOL$ABCHxxR(,,T-E-ErJ((;2r&   conditionalc                    [        U S0 5      nU(       aA  U R                  (       a  U R                  US'   O U R                  (       a  U R                  US'   U=(       d    SnU R                  U R	                  U R
                  US9S5      nUb7  U R                  c  X0l        U R                  U5        U $ U R                  X05      $ U $ )a  Re-retrieve the information for this object.

The reasoning for the return value is the following example: ::

    repos = [r.refresh() for r in g.repositories_by('kennethreitz')]

Without the return value, that would be an array of ``None``'s and you
would otherwise have to do: ::

    repos = [r for i in g.repositories_by('kennethreitz')]
    [r.refresh() for r in repos]

Which is really an anti-pattern.

.. versionchanged:: 0.5

.. _Conditional Requests:
    http://developer.github.com/v3/#conditional-requests

:param bool conditional: If True, then we will search for a stored
    header ('Last-Modified', or 'ETag') on the object and send that
    as described in the `Conditional Requests`_ section of the docs
:returns: self
CUSTOM_HEADERSzIf-Modified-SincezIf-None-MatchN)r}   r   )	r   r   r   r   r   r   r   r   r   )r   r   r}   r   s       r   refreshGitHubCore.refresh%  s    2 $ 0"5!!/3/A/A+,+/99(/Tzz$))DIIw)?E'"&''-  ''33r&   c                 ,    [         R                  " 5       $ )zoGenerate a new session.

:returns:
    A brand new session
:rtype:
    :class:`~github3.session.GitHubSession`
)r   GitHubSessionr1   s    r   new_sessionGitHubCore.new_sessionO  s     $$&&r&   )	r   r   r   r   r   r   r   r   r   )T)NT)NNNN)F)5__name__
__module____qualname____firstlineno____doc__r   r   tOptional__annotations__r   r   r    r   r.   r2   r7   classmethodr?   rH   rL   rP   rV   rZ   r^   rB   staticmethodrk   rr   r   r   r   r   r   r   r   r   r   propertyr   r   setterintstrTyper   Mappingr   r   boolr   r   __static_attributes__r$   r&   r   r	   r	      s     !,0KL)0<g&;&; <.

.   ' ' 1 1)) 3  *"H
1635:37   - - 
[[  ?C $37$(

 
 VVAY	

 

199S!**S/%9:;
 jjo
 AIIc3h/0
 **S/
 
%
:  (4 (L (T'r&   r	   )r   r   r5   loggingtypingr   dateutil.parserr:   requests.compatrC   rv   r   r   TYPE_CHECKINGr   	getLogger__package__ry   TypeVarr   r	   r$   r&   r   <module>r      sT    ?        ??$ IIcNA' A'r&   