
    fi                      .   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m	Z	m
Z
mZmZmZmZmZ d dlmZ d dlmZmZ d dlmZ d dlmZmZ d dlmZmZmZmZm Z  d dl!m"Z" d d	l#m$Z$ d d
l%m&Z&m'Z' ddl(m)Z)m*Z*  G d dej+        j,                  Z- G d de          Z,dS )    N)
CollectionDictIterableIteratorMappingOptionalSequencecast)Requirement)NormalizedNamecanonicalize_name)parse)InvalidWheelUnsupportedWheel)BaseDistributionBaseEntryPointDistributionVersionInfoPathWheel)normalize_path)TempDirectory)parse_wheelread_wheel_metadata_file   )BasePathget_dist_namec            	           e Zd ZdZdeej        ef         dej        ddfdZe	de
j        ded	edd fd
            Zdedeej                 fdZdedee         fdZdS )WheelDistributiona  An ``importlib.metadata.Distribution`` read from a wheel.

    Although ``importlib.metadata.PathDistribution`` accepts ``zipfile.Path``,
    its implementation is too "lazy" for pip's needs (we can't keep the ZipFile
    handle open for the entire lifetime of the distribution object).

    This implementation eagerly reads the entire metadata directory into the
    memory instead, and operates from that.
    filesinfo_locationreturnNc                 "    || _         || _        d S N)_filesr    )selfr   r    s      v/home/panchajanya/Development/work/volatility3/lib/python3.11/site-packages/pip/_internal/metadata/importlib/_dists.py__init__zWheelDistribution.__init__/   s    
 *    zfnamelocationc                     t          |          \  }fd                                D             }fd|D             }t          j        |          } | ||          S )Nc              3      K   | ]L}|                      d           |t          j        |                    d d          d                   fV  MdS )/r   N)
startswithpathlibPurePosixPathsplit).0r*   info_dirs     r&   	<genexpr>z1WheelDistribution.from_zipfile.<locals>.<genexpr>?   sr       
 
(~~~..
7(C););B)?@@A
 
 
 
 
 
r(   c                 8    i | ]\  }}|t          |          S  )r   )r4   fullpathrelpathr)   s      r&   
<dictcomp>z2WheelDistribution.from_zipfile.<locals>.<dictcomp>D   s:     
 
 
!' -b(;;
 
 
r(   )r   namelistr1   r2   )	clsr)   r*   r+   _pathsr   r    r5   s	    `      @r&   from_zipfilezWheelDistribution.from_zipfile7   s     ""d++!
 
 
 

 
 


 
 
 
%*
 
 
  -hAAs5-(((r(   pathc                     t          j        t          |                    | j        v rt	          | j                  S t          |          r#   )r1   r2   strr$   iterFileNotFoundErrorr%   rA   s     r&   iterdirzWheelDistribution.iterdirK   s>     T++t{::$$$%%%r(   filenamec                 
   	 | j         t          j        |                   }n# t          $ r Y d S w xY w	 |                    d          }n9# t
          $ r,}| j        j        }d| d| d| d}t          |          d }~ww xY w|S )Nzutf-8zError decoding metadata for z: z in z file)	r$   r1   r2   KeyErrordecodeUnicodeDecodeErrorr    parentr   )r%   rH   datatextewheelerrors          r&   	read_textzWheelDistribution.read_textQ   s    	;w4X>>?DD 	 	 	44		*;;w''DD! 	* 	* 	*&-ER5RRARR8RRRE"5)))	* s#   " 
00A
 

B 'A;;B )__name__
__module____qualname____doc__r   r1   r2   bytesr'   classmethodzipfileZipFilerC   r@   r   r   rG   r   rS   r8   r(   r&   r   r   $   s         +w,e34+ ,+ 
	+ + + + )O) ) 	)
 
) ) ) [)&&H &'2G)H & & & &# (3-      r(   r   c            	       H   e Zd Zdej        j        dee         dee         ddfdZe	de
defd            Ze	d	ed
e
de
defd            Ze	dede
defd            Zedee
         fd            Zedee
         fd            Zedee
         fd            Zdee
         fdZedefd            Zedefd            ZdedefdZdee
         fdZdede
fdZde e!         fdZ"de#j$        j%        fdZ&de e
         fdZ'de
defdZ(d"d e)e
         de e*         fd!Z+dS )#Distributiondistr    installed_locationr!   Nc                 0    || _         || _        || _        d S r#   )_dist_info_location_installed_location)r%   r^   r    r_   s       r&   r'   zDistribution.__init__`   s!     
+#5   r(   	directoryc                     t          j        |          }t          j        j                            |          } | |||j                  S r#   )r1   Path	importlibmetadatar]   atrM   )r=   rd   r    r^   s       r&   from_directoryzDistribution.from_directoryj   sA    Y//!.11-@@s4(<===r(   metadata_contentsrH   project_namec                     t          j        t          dd          j                  }|dz  }|                    |           t
          j        j                            |j	                  } | ||j	        d           S )Nrh   T)kindglobally_managedMETADATA)
r1   rf   r   rA   write_bytesrg   rh   r]   ri   rM   )r=   rk   rH   rl   temp_dirmetadata_pathr^   s          r&   from_metadata_file_contentsz(Distribution.from_metadata_file_contentsp   s|     <zDAAAF
 
 !:-!!"3444!.11-2FGGs4-t444r(   rQ   r*   c                    	 |                                 5 }t                              |||j                  }d d d            n# 1 swxY w Y   nN# t          j        $ r}t          |j        |          |d }~wt          $ r}t          | d|           d }~ww xY w | ||j        t          j
        |j                            S )Nz has an invalid wheel, )
as_zipfiler   r@   r+   rZ   
BadZipFiler   r   r    r1   r2   )r=   rQ   r*   r)   r^   rP   s         r&   
from_wheelzDistribution.from_wheel   s&   	H!!## Pr(55b$OOP P P P P P P P P P P P P P P! 	< 	< 	<u~t44!; 	H 	H 	H"d#F#F1#F#FGGG	Hs4+W-B5>-R-RSSSsE   A "AA AA AA BA55BBBc                 F    | j         d S t          | j         j                  S r#   )rb   rC   rM   r%   s    r&   r+   zDistribution.location   s$    &44&-...r(   c                 <    | j         d S t          | j                   S r#   )rb   rC   rz   s    r&   r    zDistribution.info_location   s!    &44&'''r(   c                 V    | j         d S t          t          | j                             S r#   )rc   r   rC   rz   s    r&   r_   zDistribution.installed_location   s)    #+4c$":;;<<<r(   c                     | j         dS t          j                            | j         j                  \  }}|dvrdS |                    dd          d         S )zrTry to get the name from the metadata directory name.

        This is much faster than reading metadata.
        N)z
.dist-infoz	.egg-info-r   r   )rb   osrA   splitextr*   r3   )r%   stemsuffixs      r&   _get_dist_name_from_locationz)Distribution._get_dist_name_from_location   s[    
 &4w''(;(@AAf4444zz#q!!!$$r(   c                 p    |                                  pt          | j                  }t          |          S r#   )r   r   ra   r   )r%   r*   s     r&   canonical_namezDistribution.canonical_name   s0    0022OmDJ6O6O &&&r(   c                 4    t          | j        j                  S r#   )parse_versionra   versionrz   s    r&   r   zDistribution.version   s    TZ/000r(   rA   c                 T    | j                             t          |                    d uS r#   )ra   rS   rC   rF   s     r&   is_filezDistribution.is_file   s#    z##CII..d::r(   c              #      K   t          | j        t          j                  sd S | j                            d                                          D ]}|j        V  d S )Nscripts)
isinstancerb   r1   rf   joinpathrG   r*   )r%   childs     r&   iter_distutils_script_namesz(Distribution.iter_distutils_script_names   sk       $-w|<< 	F(11)<<DDFF 	 	E*	 	r(   c                 v    | j                             t          |                    }|t          |          |S r#   )ra   rS   rC   rE   )r%   rA   contents      r&   rS   zDistribution.read_text   s5    *&&s4yy11?#D)))r(   c                     | j         j        S r#   )ra   entry_pointsrz   s    r&   iter_entry_pointszDistribution.iter_entry_points   s    z&&r(   c                 T    t          t          j        j        | j        j                  S r#   )r
   emailmessageMessagera   rh   rz   s    r&   _metadata_implzDistribution._metadata_impl   s     EM)4:+>???r(   c                 8    | j                             dg           S )NProvides-Extra)rh   get_allrz   s    r&   iter_provided_extrasz!Distribution.iter_provided_extras   s    }$$%5r:::r(   extrac                 l    t          fd| j                            dg           D                       S )Nc              3   X   K   | ]$}t          |          t                    k    V  %d S r#   )r   )r4   provided_extrar   s     r&   r6   z1Distribution.is_extra_provided.<locals>.<genexpr>   sM       
 
 n--1B51I1II
 
 
 
 
 
r(   r   )anyrh   r   )r%   r   s    `r&   is_extra_providedzDistribution.is_extra_provided   sN     
 
 
 
"&-"7"78H""M"M
 
 
 
 
 	
r(   r8   extrasc              #     K   d |D             }| j                             dg           D ]_}t          |          j        sV  |s!j                            ddi          rV  @t          fd|D                       rV  `d S )Nc                     g | ]}d |iS )r   r8   )r4   rP   s     r&   
<listcomp>z2Distribution.iter_dependencies.<locals>.<listcomp>   s    -K-K-Kqwl-K-K-Kr(   zRequires-Distr    c              3   L   K   | ]}j                             |          V  d S r#   )markerevaluate)r4   contextreqs     r&   r6   z1Distribution.iter_dependencies.<locals>.<genexpr>   s3      JJgSZ((11JJJJJJr(   )rh   r   r   r   r   r   )r%   r   contexts
req_stringr   s       @r&   iter_dependencieszDistribution.iter_dependencies   s      -K-KF-K-K-K-//DD 	 	Jj))C: 				 
 3 3WbM B B 				JJJJJJJJJ 				 	r(   )r8   ),rT   rU   rV   rg   rh   r]   r   r   r'   rY   rC   r   rj   rX   rt   r   rx   propertyr+   r    r_   r   r   r   r   r   r   boolr   r   r   rS   r   r   r   r   r   r   r   r   r   r   r   r   r8   r(   r&   r]   r]   _   s       6 -6  )6 %X.	6
 
6 6 6 6 >s >/? > > > [>
 5 5 5 	5
 
5 5 5 [5  Tu TC T4D T T T [T /(3- / / / X/
 (x} ( ( ( X(
 =HSM = = = X=

%hsm 
% 
% 
% 
% ' ' ' ' X' 1, 1 1 1 X1;H ; ; ; ; ;Xc]    h 3    '8N#; ' ' ' '@ 5 @ @ @ @;hsm ; ; ; ;
s 
t 
 
 
 
	 	
3 	+AV 	 	 	 	 	 	r(   r]   ).email.messager   importlib.metadatarg   r   r1   rZ   typingr   r   r   r   r   r   r	   r
   "pip._vendor.packaging.requirementsr   pip._vendor.packaging.utilsr   r   pip._vendor.packaging.versionr   r   pip._internal.exceptionsr   r   pip._internal.metadata.baser   r   r   r   r   pip._internal.utils.miscr   pip._internal.utils.temp_dirr   pip._internal.utils.wheelr   r   _compatr   r   rh   r]   r   r8   r(   r&   <module>r      s           				  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ; : : : : : I I I I I I I I @ @ @ @ @ @ C C C C C C C C              4 3 3 3 3 3 6 6 6 6 6 6 K K K K K K K K , , , , , , , ,8 8 8 8 8	*7 8 8 8vD D D D D# D D D D Dr(   