
    uYfb7              
          d dl mZ d dl mZ d dl mZ d dl 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Zd dlZd dlZd dlZd dlmZ d dl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 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 d dlmZ d dlmZ d dl Z d dl!m"Z" d dl!m#Z# g dZ$ejJ                  Z& ejN                         Z( ejR                         Z*d dl+m,Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl2m4Z4 dQde5fdZ6dQde7fdZ8ee9e:f   Z;ejx                  Z=	 d dlm>Z> d Z?d" ZB	 d d#lCmDZD 	 d d&lCmFZF 	 d d'lCmHZH 	 d d)lCmIZI  ej                         ZLd, ZMd- ZNd. ZOd/ZP	 d d0lQmRZR d1 ZS eTd      ZU eVe9e:e5e7eWeUeTeXg      ZY eVeZeeeg      Z[ eVe\e]e^eVeg      Z_e[e_z  Z`eYe`z  Za	 d d2lmbZb eeeeebe#e"efegehf
Zid3Zj	 d d4lmkZk eeeen   enee   f   ed7   f   Zo	 d d8lpmqZq d9e5deWfd:Zsd; Zt G d< d=ec      Zu	 d d>lvmwZx 	 d dAlvm|Z} 	 d dCl~mZ e&dFk\  rd dGlmZ n-e&dHk\  rd dGlmZ dRdIZee_        nd dJlmZ d dKlmZ  G dL dM      Ze&dFk\  r
d dNlmZ dP Zyd dNlmZ dO Zee_        dP Zy# e@$ r d d lmAZ> d! Z?Y Qw xY w# e@$ r d d$lCmCZE d% ZDY \w xY w# e@$ r
 d d&lGmFZF Y gw xY w# e@$ r d( ZHY ow xY w# e@$ r d d*lCmJZK d+ ZIY }w xY w# e@$ r
 d d0l mRZR Y lw xY w# e@$ r  ec       j                  j                  ZbY Nw xY w# e@$ r d d5lmlZl d d6lmmZm d dlmZ eelemef   ZkY _w xY w# e@$ r erZqY Pw xY w# e@$ r' d dlZ ej                  d?      j                  Z{d@ ZxY bw xY w# e@$ r dB Z}Y jw xY w# e@$ r d dDl~mZ edRdE       ZY ~w xY w)S    )Counter)OrderedDict)defaultdict)dequeN)iscoroutinefunction)isgeneratorfunction)mkdtemp)BuiltinFunctionType)BuiltinMethodType)FunctionType)
MethodType)TracebackType)Any)AnyStr)Optional)Text)Tuple)Type)Union)BoundFunctionWrapper)FunctionWrapper)httplibr   QueueStringIO	urlencodeparsemaybe_stringify)r   )r   )r   returnc                     t        | t              r| S t        | t              r| j                  ||      S t	        d| j
                  z        Nz%Expected str or bytes but received %r)
isinstancestrbytesdecode	TypeError	__class__sencodingerrorss      W/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/ddtrace/internal/compat.pyensure_textr,   9   sA    !S!Uxx&))
;q{{K
LL    c                     t        | t              r| S t        | t              st        d| j                  z        | j                  ||      S r    )r!   r#   r"   r%   r&   encoder'   s      r+   ensure_binaryr0   A   sA    !Ua?1;;OPP88Hf%%r-   )getfullargspecc                     |j                   xsQ |j                  xsC |j                  xs5 |j                  xs' |j                  xs |j
                  xs t        |       S N)argsvarargsvarkwdefaults
kwonlyargskwonlydefaultsr   fargspecs     r+   is_not_void_functionr=   Q   se    LL &&}}& & !!	&
 %%& #1%	
r-   )
getargspecc                     |j                   xs5 |j                  xs' |j                  xs |j                  xs t	        |       S r3   )r4   r5   keywordsr7   r   r:   s     r+   r=   r=   _   s7    ||pwp'2B2BpgFVFVpZmnoZppr-   c                 H    t        | t              xr t        | t               S )zEHelper to determine if the provided ``obj`` is an integer type or not)r!   intboolobjs    r+   
is_integerrF   c   s      c3=
3(=$==r-   )time_ns)timec                  4    t        t               dz        dz  S )Ng    .Ai  )rB   _time r-   r+   rG   rG   s   s    57T>"T))r-   )	monotonic)monotonic_nsc                  .    t        t               dz        S Ng    eA)rB   rL   rK   r-   r+   rM   rM      s    9;$%%r-   )process_time_ns)clockc                  .    t        t               dz        S rO   )rB   _process_timerK   r-   r+   rP   rP      s    =?S())r-   c                 N     t        j                         fd       }|S )a  
    Decorator factory that creates an asynchronous wrapper that yields
    a coroutine result. This factory is required to handle Python 2
    compatibilities.

    :param object tracer: the tracer instance that is used
    :param function f: the coroutine that must be executed
    :param tuple params: arguments given to the Tracer.trace()
    :param dict kw_params: keyword arguments given to the Tracer.trace()
    c                     K    j                   i 5   | i | d {   }|cd d d        S 7 # 1 sw Y   y xY wwr3   )trace)r4   kwargsresultcoro	kw_paramsparamstracers      r+   func_wrapperz*make_async_decorator.<locals>.func_wrapper   sL     V\\6/Y/ 	000F	 	0	 	s#   A 424
A 4=A )	functoolswraps)r\   rY   r[   rZ   r]   s   ```` r+   make_async_decoratorr`      s(     __T 
 r-   c                 z    t        | t              r| S t        | d      r| j                  dd      S t        |       S )z?Return a unicode string for the given bytes or string instance.r$   utf-8ignore)r*   )r!   r"   hasattrr$   r(   s    r+   
to_unicoderf      s=     !S q(xxx11 q6Mr-   c                 "    | j                         S )a2  Returns the response for a connection.

    If using Python 2 enable buffering.

    Python 2 does not enable buffering by default resulting in many recv
    syscalls.

    See:
    https://bugs.python.org/issue4879
    https://github.com/python/cpython/commit/3c43fcba8b67ea0cec4a443c755ce5f25990a6cf
    )getresponse)conns    r+   get_connection_responserj      s     r-   T)Iterablec                     | t        |       S y r3   )r"   rD   s    r+   r   r      s    
3xr-   )MethodWrapperTypebuiltins)
Collection)List)Set)NNN)JSONDecodeErroripc                 `    	 t        j                  t        |              y# t        $ r Y yw xY w)NTF)	ipaddress
ip_addressr"   	Exception)rs   s    r+   is_valid_iprx     s.    SW% s   ! 	--c                 V    t        j                  t        |             }|j                  S )z\
    is_global is Python 3+ only. This could raise a ValueError if the IP is not valid.
    )ru   rv   r"   	is_global)rs   	parsed_ips     r+   ip_is_globalr|     s$    
 $$SW-Ir-   c                   j   e Zd ZdZd
dZd Zd ZddZd Zd Z	 e
ej                        Z e
ej                  j                        Z e
ej                  j"                        Z e
ej                  j&                        Z e
ej*                        Z e
ej.                        Zej4                  Zd	 Zy)TemporaryDirectorya+  Create and return a temporary directory.  This has the same
    behavior as mkdtemp but can be used as a context manager.  For
    example:

        with TemporaryDirectory() as tmpdir:
            ...

    Upon exiting the context, the directory and everything contained
    in it are removed.
    Nc                 D    d| _         d | _        t        |||      | _        y NF)_closednamer	   )selfsuffixprefix_dirs       r+   __init__zTemporaryDirectory.__init__0  s     	FFD1	r-   c                 b    dj                  | j                  j                  | j                        S )Nz	<{} {!r}>)formatr&   __name__r   r   s    r+   __repr__zTemporaryDirectory.__repr__5  s#    !!$.."9"9499EEr-   c                     | j                   S r3   )r   r   s    r+   	__enter__zTemporaryDirectory.__enter__8  s    yyr-   c                 "   | j                   rY| j                  sL	 | j                  | j                          d| _        |r&| j                  dj                  |       t               y y y y # t        t        f$ r}dt        |      vr Y d }~y d }~ww xY w)NNoneTzImplicitly cleaning up {!r})	r   r   _rmtreer%   AttributeErrorr"   _warnr   ResourceWarning)r   r   exs      r+   cleanupzTemporaryDirectory.cleanup;  s    99T\\TYY'  DL

8??EW  *9 ~.  R(s   A' 'B6B		Bc                 $    | j                          y r3   r   )r   excvaluetbs       r+   __exit__zTemporaryDirectory.__exit__J  s    r-   c                 (    | j                  d       y )NT)r   r   r   s    r+   __del__zTemporaryDirectory.__del__M  s    4 r-   c                 n   | j                  |      D ]`  }| j                  ||      }	 | j                  |      xr | j                  |       }|r| j                  |       O	 | j                  |       b 	 | j                  |       y # t        $ r d}Y Hw xY w# t        $ r Y w xY w# t        $ r Y y w xY wr   )_listdir
_path_join_isdir_islinkOSErrorr   _remove_rmdir)r   pathr   fullnameisdirs        r+   r   zTemporaryDirectory._rmtree]  s     MM$' 	DtT2HH-Ldll86L2L X&LL*		KK      		s5   %B"B6B( BB	B%$B%(	B43B4) tmpN)F)r   
__module____qualname____doc__r   r   r   r   r   r   staticmethodoslistdirr   r   joinr   r   r   islinkr   remover   rmdirr   warningswarnr   r   rK   r-   r+   r~   r~   $  s    	2
FX! BJJ'Hbggll+J"''--(F277>>*G299%G"((#FMMEr-   r~   )quotez[^\w@%+=:,./-]c                 R    | syt        |       | S d| j                  dd      z   dz   S )z1Return a shell-escaped version of the string *s*.z'''z'"'"')_find_unsafereplacere   s    r+   shquoter   z  s6     ?"H QYYsI..44r-   r   c                 2    dj                  d | D              S )z*Return a shell-escaped string from *args*. c              3   2   K   | ]  }t        |        y wr3   )r   ).0args     r+   	<genexpr>zshjoin.<locals>.<genexpr>  s     55s   r   )r4   s    r+   shjoinr     s     xx5555r-   )nullcontext)contextmanagerc              #      K   |  y wr3   rK   )enter_results    r+   r   r     s     s   )   	   )singledispatchmethod)r      c                     t        |d      r!t        |d|j                  j                         | j                  j                  ||      S N__func____annotations__)funcrd   setattrr   r   
dispatcherregisterr   clsmethods      r+   	_registerr     s=    3
#C*CLL,H,HI''&'99r-   )singledispatch)update_wrapperc                   6    e Zd ZdZd ZddZddZed        Zy)r   zSingle-dispatch generic method descriptor.

        Supports wrapping existing descriptors and handles non-descriptor
        callables as instance methods.
        c                 |    t        |      st        |d      st        |d      t        |      | _        || _        y )N__get__z  is not callable or a descriptor)callablerd   r%   r   r   r   )r   r   s     r+   r   zsingledispatchmethod.__init__  s8    D>'$	*B4(*J KLL,T2DODIr-   Nc                     t        |d      r!t        |d|j                  j                         | j                  j                  ||      S r   r   r   s      r+   r   zsingledispatchmethod.register  s=    sJ'.0L0LM??++Cf+==r-   c                       fd} j                   |_          j                  |_        t        | j                         |S )Nc                      j                   j                  | d   j                        } |j                        | i |S )Nr   )r   dispatchr&   r   )r4   rW   r   r   rE   r   s      r+   _methodz-singledispatchmethod.__get__.<locals>._method  s>    11$q'2C2CD/v~~c3/@@@r-   )__isabstractmethod__r   r   r   )r   rE   r   r   s   ``` r+   r   zsingledispatchmethod.__get__  s8    A ,0+D+DG(#}}G7DII.Nr-   c                 0    t        | j                  dd      S )Nr   F)getattrr   r   s    r+   r   z)singledispatchmethod.__isabstractmethod__  s    499&<eDDr-   r3   )	r   r   r   r   r   r   r   propertyr   rK   r-   r+   r   r     s,    			>
	 
	E 
	Er-   r   )Pathc                 F    	 | j                  |       y# t        $ r Y yw xY w)z=Return True if the path is relative to another path or False.TF)relative_to
ValueError)r   others     r+   is_relative_tor     s*    	U# 		s    	  c                  ^    t        j                  t        j                  dk7  rd      S d      S )Nwin32forkspawn)multiprocessingget_contextsysplatformrK   r-   r+   get_mp_contextr     s&    &&1HvVVgVVr-   )rb   rc   r3   )collectionsr   r   r   r   r^   inspectr   r   ru   r   r   r   rer   tempfiler	   	threadingtypesr
   r   r   r   r   typingr   r   r   r   r   r   r   r   ddtrace.vendor.wrapt.wrappersr   r   __all__version_infoPYTHON_VERSION_INFOpython_versionPYTHON_VERSIONpython_implementationPYTHON_INTERPRETERhttp.clientclientr   ior   queuer   urllib.parser   r   r"   r,   r#   r0   rB   floatNumericTypePatternpattern_typer1   r=   ImportErrorr>   rF   rH   rG   rJ   rL   ddtrace.vendor.monotonicrM   rP   rQ   rS   main_threadr`   rf   rj   CONTEXTVARS_IS_AVAILABLEcollections.abcrk   r   typeNoneType	frozensetrC   complexBUILTIN_SIMPLE_TYPESdictBUILTIN_MAPPNG_TYPESlisttuplesetBUILTIN_SEQUENCE_TYPESBUILTIN_CONTAINER_TYPESBUILTIN_TYPESrm   objectr   r&   r   classmethodr   CALLABLE_TYPESBUILTINro   rp   rq   BaseExceptionExcInfoTypejsonrr   r   rx   r|   r~   shlexr   r   compilesearchr   r   r   
contextlibr   r   r   r   r   r   r   pathlibr   r   r   rK   r-   r+   <module>r/     s&    # #   ' '   	  	 
   % #            > 9 &&  )((*3X335      "M M&5 & CJ zzq&	
$>*3
&!*$ $i##%,($   %(
 : #uc5$$PW!XY  $Wk!JK "D%i#GH .1GG $'>>4'  )! E$}-}h}>UUVX]^nXoop!$
C D L L^5&&6$& & .F" /:
 %.!((E ED &  W  )DWG  q4qq(  *"**  3223  &&&  *+**X  %$$%.  4))334(  )tS%'(J)  ! O!R  52::/077L
55(  666  ) 	s   	I "I3 )J 0J 7J) J> K 4K7 L .L+ 5M <M) I0/I03JJJJJ&%J&)J;:J;>KK K43K47LLL('L(+(MMM&%M&)N N