
    uYfJ                        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  e j                  e      Z	 ej$                  Z ej(                  dd	efd
efdej,                  e   fg      Zed        Zde	de	defdZde	defdZedej,                  ej6                  eef      fd       Z e       dej:                  ee	f   dej,                  e   fd       Z e       dedej,                  e   fd       Z e	 ej@                  d            jC                         Z" e	 ej@                  d            jC                         Z# e	 ej@                  d            jC                         Z$ e	 ej@                  d            jC                         Z% e       de	de&fd       Z' e       d	ede&fd       Z(y# e$ r d ZY w xY w)    N)
ModuleType)Path)origin)cached)calloncec                 p   t        | t        t        f      r| S t        |       }	 |j	                  |       }t        |t        t        f      r|S t        dj                  |j                  t        |      j                              # t
        $ r& t        |d      r t        d|j                  z         w xY w)au  Return the path representation of a path-like object.

        If str or bytes is passed in, it is returned unchanged. Otherwise the
        os.PathLike interface is used to get the path representation. If the
        path representation is not str or bytes, TypeError is raised. If the
        provided path is not str, bytes, or os.PathLike, TypeError is raised.
        
__fspath__z/expected str, bytes or os.PathLike object, not z7expected {}.__fspath__() to return str or bytes, not {})

isinstancestrbytestyper	   AttributeErrorhasattr	TypeError__name__format)path	path_type	path_reprs      Y/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/ddtrace/internal/packages.pyfspathr      s     dS%L)K J		h!,,T2I i#u.VI..Y0H0HI
 	
  	hy,/ QT]TfTf fgg		hs   B /B5Distributionnameversionr   c                  :   	 ddl m}  t	               }| j                         D ]c  }t        |j                  d            }|j                  }|d   }|d   }|s6|s9|j                  t        ||j                         |             e |S # t        $ r ddl} Y w xY w)zBreturns the name and version of all distributions in a python pathr   N r   r   )r   r   r   )importlib.metadatametadataImportErrorimportlib_metadatasetdistributionsr   locate_fileaddr   lower)r    pkgsdistr   r   r   r   s          r   get_distributionsr(   7   s    "7 5D"002 	R4##B'( ==9%GHH\t$**,PQ	R K  "!"s   B
 
BBrel_pathparentreturnc                     | j                   d   }||z  }|j                         r|dz  j                         r|S dj                  | j                   d d       S )Nr   __init__.py/   )partsis_direxistsjoin)r)   r*   baseroots       r   _effective_rootr6   O   sU    >>!DD=D;;=d]&:%B%B%D4f#((S[SaSabdcdSeJff    c                    t         t        fD ]  }	 t        | j                  |      |      c S  d x}}d t
        j                  D        D ]E  }	 | j                  |      }|+t        |j                        t        |j                        k  r||}}G |%	 t        |t        j                  t        |            S d|  }t	        |      # t        $ r Y w xY w# t        $ r Y w xY w# t        $ r Y 9w xY w)Nc              3   N   K   | ]  }t        |      j                           y wN)r   resolve).0_s     r   	<genexpr>z_root_module.<locals>.<genexpr>a   s     <aQ)<s   #%z$Could not find root module for path )purelib_pathplatlib_pathr6   relative_to
ValueErrorsysr   lenparentstcastr   
IndexError)r   parent_pathmin_relative_pathmax_parent_pathrelativemsgs         r   _root_modulerN   U   s   $l3 	"4#3#3K#@+NN +/.<388< 	''4H (C0@0@,ACHYHaHaDb,b5={?!	 $	"#4affT?6STT 1
7C
S/-  		  		  		s6   C	AC#C' 		CC	C$#C$'	C32C3c                  :   	 dd l m}  i d| j                  ffd}	 i }| j                         D ]  }||j                  t        |j                  d   |j                  d       }|j                  D ]i  }|j                  d   }|j                  d      s|j                  d      s|dk(  r: ||      rd	j                  |j                  d d
       }||vse|||<   k  |S # t        $ r dd l} Y w xY w# t        $ r t        j                  dd       Y y w xY w)Nr   fc                    | j                   d   }	 |   S # t        $ r Y nw xY wt        | j                         dk  rd|<   yt        j                  t
        | j                               }|j                  t        | j                         dz
     }|j                         r|dz  j                         sd|<   yd|<   y)Nr   r/   Fr-   T)
r0   KeyErrorrD   rF   rG   r   locaterE   r1   r2   )rP   r5   	located_fr*   
namespacess       r   is_namespacez6_package_for_root_module_mapping.<locals>.is_namespace|   s    wwqz	d## 		 qww<!$JtFF4,	""3qww<!#34==?F]$:#B#B#D#Jt 
4s    	##r   )r   r   r   z
.dist-infoz	.egg-infoz..r.   r/   ziUnable to build package file mapping, please report this to https://github.com/DataDog/dd-trace-py/issuesT)exc_info)r   r   r   r    PackagePathr"   filesr   r   r0   endswithr3   	ExceptionLOGwarning)r   rV   mappingr'   drP   r5   rU   s          @r    _package_for_root_module_mappingr`   s   s0   .- %'J,, (**, 
	*DDJJ$: dmmF&;T\\X\] *A771:D}}\2dmmK6PTX\`T` #A"xx47*()*
	* Q  .-.T  R 	 	

 s4   C$ C7 C7 BC7 
C7 $C43C47 DDfilenamec                     t               }|y 	 t        | t              rt        |       n| }|j	                  t        |j                                     S # t        $ r Y y w xY wr:   )r`   r
   r   r   getrN   r;   rB   )ra   r^   r   s      r   filename_to_packagerd      sW    .0G!+Hc!:tH~{{<788 s   AA 	A A modulec                 6    t        |       }|t        |      S dS )z-Returns the package distribution for a moduleN)r   rd   )re   module_origins     r   module_to_packagerh      s$     6NM1>1J}-TPTTr7   stdlib
platstdlibpurelibplatlibc                     | j                         }|j                  t              xs |j                  t              xr- |j                  t              xs |j                  t
               S r:   )r;   is_relative_tostdlib_pathplatstdlib_pathr?   r@   )r   rpaths     r   	is_stdlibrr      sY    LLNE  -V1E1Eo1V \*Pe.B.B<.P] r7   c                     	 ddl m} 	 |j	                  |        y# t        $ r ddl}Y "w xY w# |j
                  $ r Y yw xY w)zDDetermine if a distribution is available in the current environment.r   NFT)r   r   r   r    distributionPackageNotFoundError)r   r    s     r   is_distribution_availablerv      sO    "7''-   "!"
 22 s    . ++A A ))loggingosrC   	sysconfigtypesr   typingrF   ddtrace.internal.compatr   ddtrace.internal.moduler   ddtrace.internal.utils.cacher   r   	getLoggerr   r\   r   r   
NamedTupler   Optionalr   r(   r6   rN   Dictr`   Unionrd   rh   get_pathr;   ro   rp   r?   r@   boolrr   rv    r7   r   <module>r      sD    	 
    ( * / 1 g! 
YYFD q||Nfc]Y<LvWXWaWabeWfNg,hi 
 
.gd gD gS gt  < 
3!**QVVC<M5N*O 3 
3l 	!''#t)"4 	L9Q 	 
	 Uj UQZZ-E U 
U %9%%h/088:)y)),78@@B&I&&y12::<&I&&y12::< D T  
 C D  
w  


s   G GG