o
    h                     @   s  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 erFd dlm	Z	 d dlm
Z
 d dlmZ d dlmZ d d	lmZ d d
lmZ edZe jd  dkZe jd  dkoZe jd dkZe jd  dkohe jd dkZe jd  dkove jd dkZe jd  dkoe jd dkZerd dlZeZeefZeeefZeefZdd Z e!e"fZ#dd Z$dd Z%dd Z&dd Z'e(d dd Z)n9d dlm*Z* d dl+m,Z eZefZeefZefZd d Z e-e!e"fZ#d!d Z$d"d Z%d#d Z&d$d Z'd+d%d&Z.ej)Z)d'd( Z/d)d* Z0dS ),    N)datetime	timedeltawraps)TYPE_CHECKING)Optional)Tuple)Any)Type)TypeVar)CallableT            
      c                 C      |   S N)	iteritemsx r   U/var/www/html/aiguide_backend/venv/lib/python3.10/site-packages/sentry_sdk/_compat.py<lambda>!       r   c                   C   s   t  S r   )r   utcnowr   r   r   r   datetime_utcnow$   s   r   c                 C   s
   t | S r   )r   utcfromtimestamp	timestampr   r   r   utc_from_timestamp(   s   
r"   c                 C   s2   | j d d d | j }|d t| jd  }|S )N   <   i  )dayssecondsfloatmicroseconds)deltar&   millisecondsr   r   r   duration_in_milliseconds,   s   r+   c                 C   s   | j | _dd | _ | S )Nc                 S   s   t | dS )Nzutf-8)unicodeencoder   r   r   r   r   5   s    z implements_str.<locals>.<lambda>)__str____unicode__)clsr   r   r   implements_str2   s   
r1   z5def reraise(tp, value, tb=None):
 raise tp, value, tbc                    s(   t |  t| G  fddd}|S )z
        Decorator which creates a contextmanager that can also be used as a
        decorator, similar to how the built-in contextlib.contextmanager
        function works in Python 3.2+.
        c                       s0   e Zd Z fddZdd Zdd Zdd Zd	S )
z/contextmanager.<locals>.DecoratorContextManagerc                    s    |i || _ d S r   the_contextmanagerselfargskwargscontextmanager_funcr   r   __init__F   s   z8contextmanager.<locals>.DecoratorContextManager.__init__c                 S   s   | j   d S r   )r3   	__enter__)r5   r   r   r   r;   J      z9contextmanager.<locals>.DecoratorContextManager.__enter__c                 _   s   | j j|i | d S r   )r3   __exit__r4   r   r   r   r=   N   s   z8contextmanager.<locals>.DecoratorContextManager.__exit__c                    s   t   fdd}|S )Nc                     s:   j   | i |}W d    |S 1 sw   Y  |S r   r2   )r6   r7   
return_valdecorated_funcr5   r   r   when_calledT   s   
zMcontextmanager.<locals>.DecoratorContextManager.__call__.<locals>.when_calledr   )r5   r@   rA   r   r?   r   __call__R   s   z8contextmanager.<locals>.DecoratorContextManager.__call__N)__name__
__module____qualname__r:   r;   r=   rB   r   r8   r   r   DecoratorContextManagerD   s
    rF   )
contextlibcontextmanagerr   )funcrF   r   r8   r   rH   ;   s   
rH   )timezonec                 C   r   r   )itemsr   r   r   r   r   g   r   c                   C   s   t tjS r   )r   nowrJ   utcr   r   r   r   r   j      c                 C   s   t | tjS r   )r   fromtimestamprJ   rM   r    r   r   r   r"   n   r<   c                 C   s   | t dd S )Nr   )r*   )r   )r)   r   r   r   r+   r   r<   c                 C   s   | S r   r   r   r   r   r   r1   v   s   c                 C   s$   |d usJ |j |ur|||r   )__traceback__with_traceback)tpvaluetbr   r   r   reraisez   s   

rU   c                    s&   G  fdddt }t |ddi S )Nc                       s   e Zd Z fddZdS )z!with_metaclass.<locals>.MetaClassc                    s   | |S r   r   )metaclsname
this_basesdbasesmetar   r   __new__   rN   z)with_metaclass.<locals>.MetaClass.__new__N)rC   rD   rE   r]   r   rZ   r   r   	MetaClass   s    r^   temporary_classr   )typer]   )r\   r[   r^   r   rZ   r   with_metaclass   s   ra   c                  C   sv   zddl m}  W n
 ty   Y d S w d| v rd S ddlm} t| dd |v r9ddlm	} |t
d d S d S )	Nr   )optthreads)FALSE_VALUESzenable-threads0)warnzWe detected the use of uwsgi with disabled threads.  This will cause issues with the transport you are trying to use.  Please enable threading for uwsgi.  (Add the "enable-threads" flag).)uwsgirb   ImportErrorsentry_sdk.constsrd   strgetlowerwarningsrf   Warning)rb   rd   rf   r   r   r   check_thread_support   s    ro   r   )1sysrG   r   r   	functoolsr   sentry_sdk._typesr   typingr   r   r	   r
   r   r   r   version_infoPY2PY33PY37PY310PY311urlparser,   	text_typerj   string_typesintlongr'   number_types	int_typesr   	bytearray
memoryviewbinary_sequence_typesr   r"   r+   r1   execrH   rJ   urllib.parseparsebytesrU   ra   ro   r   r   r   r   <module>   s`    

%


