
    _Og
                     h    S r SSKJr  SSKrSSKrSSKJr  \R                  " S5      r	SS jr
SS jrg)	z!A collection of useful utilities.    N)compatz^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])(T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?)?$c                 R   U c  U(       a  g[        S5      e[        U [        R                  5      (       a  U R                  5       S-   $ [        U [        R
                  5      (       a*  [        R                  U 5      (       d  [        SU -  5      eU $ [        S[        U 5      -  5      e)a  Function to check the conformance of timestamps passed by users.

This will check that a string is a valid format and allow users to pass a
datetime object which we will then convert to a proper ISO8601 date-time
string.

:param timestamp: string to be validated or datetime object to be
    converted.
:param bool allow_none: whether or not to allow timestamp to be None.
    Default: ``True``
:returns: valid ISO8601 string
:rtype: str
:raises: ValueError
NzTimestamp value cannot be NoneZz<Invalid timestamp: %s is not a valid ISO-8601 formatted datez#Cannot accept type %s for timestamp)	
ValueError
isinstancedatetime	isoformatr   
basestringISO_8601matchtype)	timestamp
allow_nones     R/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/github3/utils.pytimestamp_parameterr      s     9::)X..//""$s**)V..//~~i((& 	  
:T)_L
MM    c                    SnSnSnU(       aK  [        [        USS5      [        R                  5      (       a  SnUn[        USS5      nOK[	        US5      nUnO<U R
                  S   nUR                  S5      [        S5      -   nXVS n[	        US5      nU R                  S	S
9 H  nUR                  U5        M     U(       d  UR                  5         U$ )aX  Stream a response body to the specified file.

Either use the ``path`` provided or use the name provided in the
``Content-Disposition`` header.

:param response: A Response object from requests
:type response: requests.models.Response
:param str path: The full path and file name used to save the response
:return: path to the file
:rtype: str
FNwriteTnamewbzcontent-dispositionz	filename=i   )
chunk_size)r   getattrabc_collectionsCallableopenheadersfindleniter_contentr   close)responsepath
pre_openedfdfilenameheaderichunks           r   stream_response_to_filer)   6   s     J	BHgdGT2O4L4LMMJBr640HdD!BH!!"78KK$s;'77":(D!&&#&6
 7 

Or   )T)N)__doc__collections.abcabcr   r   rerequestsr   compiler   r   r)    r   r   <module>r1      s5    ' )  	  ::"NJ#r   