
    Rhm                        d Z ddlZddlmZ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ZddgZej                  Zej                  dd Z G d de      Zi Z ee
      ZdZd	Zd
Z G d dej2                        Zedz   ddfedz   ddfddfZd Zd Zd Zd ZdZ da!d Z"d Z#d Z$d Z% ee%jL                        Z'd Z(d Z)d Z*d Z+d Z,d  Z-y)!aP  zipimport provides support for importing Python modules from Zip archives.

This module exports three objects:
- zipimporter: a class; its constructor takes a path to a Zip archive.
- ZipImportError: exception raised by zipimporter objects. It's a
  subclass of ImportError, so it can be caught as ImportError, too.
- _zip_directory_cache: a dict, mapping archive paths to zip directory
  info dicts, as used in zipimporter._files.

It is usually not needed to use the zipimport module explicitly; it is
used by the builtin import mechanism for sys.path items that are paths
to Zip archives.
    N)_unpack_uint16_unpack_uint32ZipImportErrorzipimporter   c                       e Zd Zy)r   N)__name__
__module____qualname__      /usr/lib/python3.12/zipimport.pyr   r   "   s    r      s   PKi  c                   T    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zy)r   a  zipimporter(archivepath) -> zipimporter object

    Create a new zipimporter instance. 'archivepath' must be a path to
    a zipfile, or to a specific path inside a zipfile. For example, it can be
    '/tmp/myimport.zip', or '/tmp/myimport.zip/mydirectory', if mydirectory is a
    valid directory inside the archive.

    'ZipImportError is raised if 'archivepath' doesn't point to a valid Zip
    archive.

    The 'archive' attribute of zipimporter objects contains the name of the
    zipfile targeted.
    c                    t        |t              st        dt        |            |st	        d|      t
        r|j                  t
        t              }g }	 	 t        j                  |      }|j                  dz  dk7  rt	        d|      	 	 t        |   }|| _        || _        t        j(                  |d d d    | _        | j*                  r| xj*                  t        z  c_        y y # t        t        f$ r@ t        j                  |      \  }}||k(  rt	        d|      |}|j                  |       Y nw xY w# t         $ r t#        |      }|t        |<   Y w xY w)Nzexpected str, not zarchive path is emptypathi   i   znot a Zip file)
isinstancestr	TypeErrortyper   alt_path_sepreplacepath_sep_bootstrap_external
_path_statst_modeOSError
ValueError_path_splitappend_zip_directory_cacheKeyError_read_directory_filesarchive
_path_joinprefix)selfr   r)   stdirnamebasenamefiless          r   __init__zzipimporter.__init__@   sY   $$0d?@@ !8tDD<<h7D(33D9 JJ)h6()9EE	/(.E )44fTrTlC;;KK8#K 1 Z( ( %8$C$CD$I!d?()9EEh'( (  	/#D)E). &	/s%   C, 	D? ,AD;:D;?EENc                    t        | |      }|t        j                  || |      S t        | |      }t	        | |      rK| j
                   t         | }t        j                  |dd      }|j                  j                  |       |S y)zkCreate a ModuleSpec for the specified module.

        Returns None if the module cannot be found.
        N)
is_packageT)nameloaderr1   )
_get_module_info
_bootstrapspec_from_loader_get_module_path_is_dirr'   r   
ModuleSpecsubmodule_search_locationsr"   )r*   fullnametargetmodule_infomodpathr   specs          r   	find_speczzipimporter.find_spech   s    
 'tX6"..x+VV 'tX6GtW% ,,z';!,,(48<>//66t<r   c                 &    t        | |      \  }}}|S )zget_code(fullname) -> code object.

        Return the code object for the specified module. Raise ZipImportError
        if the module couldn't be imported.
        _get_module_coder*   r;   code	ispackager>   s        r   get_codezzipimporter.get_code   s     $4D(#C ir   c                 H   t         r|j                  t         t              }|}|j                  | j                  t        z         r|t        | j                  t        z         d }	 | j                  |   }t        | j                  |      S # t        $ r t        dd|      w xY w)zget_data(pathname) -> string with file data.

        Return the data associated with 'pathname'. Raise OSError if
        the file wasn't found.
        Nr    )
r   r   r   
startswithr'   lenr&   r$   r   	_get_data)r*   pathnamekey	toc_entrys       r   get_datazzipimporter.get_data   s     ''h?Ht||h673t||h6789C	&C(I y11  	&!R%%	&s   %B
 
B!c                 &    t        | |      \  }}}|S )zget_filename(fullname) -> filename string.

        Return the filename for the specified module or raise ZipImportError
        if it couldn't be imported.
        rB   rD   s        r   get_filenamezzipimporter.get_filename   s     $4D(#C ir   c                    t        | |      }|t        d||      t        | |      }|rt        j                  |d      }n| d}	 | j
                  |   }t        | j                  |      j                         S # t        $ r Y yw xY w)zget_source(fullname) -> source string.

        Return the source code for the specified module. Raise ZipImportError
        if the module couldn't be found, return None if the archive does
        contain the module, but has no source for it.
        Ncan't find module r2   __init__.py.py)
r4   r   r7   r   r(   r&   r$   rL   r'   decode)r*   r;   mir   fullpathrO   s         r   
get_sourcezzipimporter.get_source   s     dH-: #5h\!BRRh/*55dMJHs|H	H-I y188::  		s   
A= =	B	B	c                 B    t        | |      }|t        d||      |S )zis_package(fullname) -> bool.

        Return True if the module specified by fullname is a package.
        Raise ZipImportError if the module couldn't be found.
        rT   rU   )r4   r   )r*   r;   rY   s      r   r1   zzipimporter.is_package   s/     dH-: #5h\!BRR	r   c                    d}t        j                  |t               t        | |      \  }}}t        j
                  j                  |      }|t        |t              st        |      }|t        j
                  |<   | |_	        	 |r4t        | |      }t        j                  | j                  |      }|g|_        t        |d      st         |_        t        j"                  |j$                  ||       t'        ||j$                         	 t        j
                  |   }t-        j.                  d||       |S #  t        j
                  |=  xY w# t(        $ r t+        d|d      w xY w)a@  load_module(fullname) -> module.

        Load the module specified by 'fullname'. 'fullname' must be the
        fully qualified (dotted) module name. It returns the imported
        module, or raises ZipImportError if it could not be imported.

        Deprecated since Python 3.10. Use exec_module() instead.
        zrzipimport.zipimporter.load_module() is deprecated and slated for removal in Python 3.12; use exec_module() instead__builtins__zLoaded module z not found in sys.moduleszimport {} # loaded from Zip {})	_warningswarnDeprecationWarningrC   sysmodulesgetr   _module_type
__loader__r7   r   r(   r'   __path__hasattrr^   _fix_up_module__dict__execr$   ImportErrorr5   _verbose_message)	r*   r;   msgrE   rF   r>   modr   rZ   s	            r   load_modulezzipimporter.load_module   sB   Cs./#3D(#C ikkooh';jl;x(C$'CKK!	 (h7.99$,,M (z3/#/ ..s||XwOs||$
	V++h'C 	##$DhPWX
	H%  	Vxl:STUU	Vs   BD5 	E 5E	E%c                 f    	 | j                  |      sy	 ddlm}  || |      S # t        $ r Y yw xY w)zReturn the ResourceReader for a package in a zip file.

        If 'fullname' is a package within the zip file, return the
        'ResourceReader' object for the package.  Otherwise return None.
        Nr   )	ZipReader)r1   r   importlib.readersrr   )r*   r;   rr   s      r   get_resource_readerzzipimporter.get_resource_reader   sA    	??8, - 	0x((  		s   $ 	00c                     	 t        | j                        | _        | j                  t        | j                  <   y# t        $ r* t        j                  | j                  d       i | _        Y yw xY w)z)Reload the file data of the archive path.N)r%   r'   r&   r#   r   popr*   s    r   invalidate_cacheszzipimporter.invalidate_caches  sT    	)$,,7DK15 . 	 $$T\\48DK	s   7: 0A-,A-c                 F    d| j                    t         | j                   dS )Nz<zipimporter object "z">)r'   r   r)   rw   s    r   __repr__zzipimporter.__repr__  s!    &t||nXJt{{m2NNr   N)r	   r
   r   __doc__r/   r@   rG   rP   rR   r[   r1   rp   rt   rx   rz   r   r   r   r   r   .   sA    "%$P62*	;4	(V)Or   z__init__.pycTrV   F)z.pycTF)rW   FFc                 D    | j                   |j                  d      d   z   S )N.   )r)   
rpartition)r*   r;   s     r   r7   r7   +  s!    ;;,,S1!444r   c                 0    |t         z   }|| j                  v S r{   )r   r&   )r*   r   dirpaths      r   r8   r8   /  s     XoGdkk!!r   c                 h    t        | |      }t        D ]  \  }}}||z   }|| j                  v s|c S  y r{   )r7   _zip_searchorderr&   )r*   r;   r   suffix
isbytecoderF   rZ   s          r   r4   r4   8  sD    D(+D)9 %
I&=t{{" r   c           	      
   	 t        j                  |       }|5  |j	                         }	 	 |j                  t         d       |j	                         }|j                  t              }t        |      t        k7  rt        d| |       |d d t        k7  r	 |j                  dd       |j	                         }t        |t        z
  t        z
  d      }	 |j                  |       |j                         }|j                  t              }|dk  rt        d| |       |||t        z    }t        |      t        k7  rt        d| |       |t        |      z
  |z   }t        |d	d
       }	t        |d
d       }
||	k  rt        d| |       ||
k  rt        d| |       ||	z  }||
z
  }|dk  rt        d| |       i }d}	 |j                  |       	 |j                  d      }t        |      dk  rt        d      |d d dk7  rnt        |      dk7  rt        d      t        |dd       }t        |dd	       }t        |d	d       }t        |dd
       }t        |d
d       }t        |dd       }t        |dd       }t        |dd       }t        |dd       }t        |dd       }t        |dd       }||z   |z   }	||
kD  rt        d| |       ||z  }	 |j                  |      }t        |      |k7  rt        d| |       	 t        |j                  |	|z
              |	|z
  k7  rt        d| |       	 |dz  r|j!                         }n	 |j!                  d      }|j)                  dt*              }t-        j.                  | |      }||||||||f}|||<   |d z  }	 |j                  |       	 d d d        t1        j2                  d!|        S # t        $ r t        d| |       w xY w# t        $ r t        d| |       w xY w# t        $ r t        d| |       w xY w# t        $ r t        d| |       w xY w# t        $ r t        d| |       w xY w# t        $ r t        d| |       w xY w# t        $ r t        d| |       w xY w# t"        $ r( |j!                  d      j%                  t&              }Y qw xY w# |j                  |       w xY w# 1 sw Y   8xY w)"Nzcan't open Zip file: r   r   can't read Zip file:    r   znot a Zip file: zcorrupt Zip file:          zbad central directory size: zbad central directory offset: z&bad central directory size or offset: .   EOF read where not expecteds   PK   
                   "   *   zbad local header offset: i   asciilatin1/r   z!zipimport: found {} names in {!r})_io	open_coder   r   tellseekEND_CENTRAL_DIR_SIZEreadrK   STRING_END_ARCHIVEmaxMAX_COMMENT_LENrfindr   EOFErrorr   rX   UnicodeDecodeError	translatecp437_tabler   r   r   r(   r5   rm   )r'   fpstart_offsetheader_positionbuffer	file_sizemax_comment_startdataposheader_sizeheader_offset
arc_offsetr.   countflagscompresstimedatecrc	data_size	name_size
extra_sizecomment_sizefile_offsetr2   r   ts                              r   r%   r%   W  s   P]]7# 
 s" wwyn	"X--q1"$'')!56 6{22$'<WK%HwWWbqz//7GGAqM "	I %(	O(C(<)=>?%A!7GG-.779D jj!347(+;G;)G.57 7c#&:":;v;"66(+=g[)I.57 7"+c$i"7#"=(27K*6"R=9M,$'CG;%OV]^^.$'Eg[%QX_``{*O(=8JA~$'Mg[%Y`ghhEEX( v;?"#@AA"1:.v;"$"#@AA&va|4)&B-8%fRm4%fRm4$VBr]3*6"R=9	*6"R=9	*6"R=9	+F2bM:
-fRm<,VBr];'*4|C.(+DWK)PW^__z)\779-D t9	)(+@)LSZ[[\277;#:;<i@WW,/DWK-PW^__ X
 5=;;=DL#{{73 ||C2*55gtD8Y	;dTWXd
m  d GGL!gs"h  CUGTLq  P4WK@wOOP  X$'<WK%HwWWX  7(+@)L.57 77  7(+@)L.57 77:  X$'<WK%HwWWX:  \(+@)LSZ[[\  \(+@)LSZ[[\ . L#{{84>>{KL GGL!gs" s"s   O& S;<P(.S%"P 9S%!P=5CS%QD
S%$Q75S%3RS%R10AS%3S;&P PS% P::S%=QS%Q44S%7RS%R..S%1-S"S%!S""S%%S88S;;Tu   	
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñÑªº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ c                      t         r t        j                  d       t        d      da 	 ddlm}  	 da t        j                  d       | S # t        $ r! t        j                  d       t        d      w xY w# da w xY w)Nzzipimport: zlib UNAVAILABLE)can't decompress data; zlib not availableTr   
decompressFzzipimport: zlib available)_importing_zlibr5   rm   r   zlibr   	Exceptionr   s    r   _get_decompress_funcr     s     	##$ABHIIO #
   ;<  J##$ABHIIJ  s   A
 
*A44A7 7A;c                    |\  }}}}}}}}	|dk  rt        d      t        j                  |       5 }
	 |
j                  |       |
j                  d      }t        |      dk7  rt        d      |d d dk7  rt        d	| |       t        |d
d       }t        |dd       }d|z   |z   }||z  }	 |
j                  |       |
j                  |      }t        |      |k7  rt	        d      	 d d d        |dk(  rS 	 t               } |d      S # t        $ r t        d| |       w xY w# t        $ r t        d| |       w xY w# 1 sw Y   ^xY w# t        $ r t        d      w xY w)Nr   znegative data sizer   r   r   r   r   s   PKzbad local file header:    r   zzipimport: can't read datar   i)r   r   r   r   r   r   rK   r   r   r   r   )r'   rO   datapathr   r   r   r   r   r   r   r   r   r   r   r   raw_datar   s                    r   rL   rL     s   MVJHh	9k4s1}122	w	 82	TGGK  v;"899"1:& #:7+!FWUU"6"R=1	#F2bM2
9nz1{"	TGGK  779%x=I%677 &/84 1}J)+
 h$$?  	T #8!D7SS	T   	T #8!D7SS	T)8 8B  JHIIJsG   E	DA+E	0D,*E	<
E D))E	,EE		EE*c                 $    t        | |z
        dk  S )Nr   )abs)t1t2s     r   	_eq_mtimer   ?  s    rBw<1r   c                 \   ||d}t        j                  |||      }|dz  dk7  }|r{|dz  dk7  }t        j                  dk7  r|st        j                  dk(  rt	        | |      }	|	t        j
                  t         j                  |	      }
t        j                  ||
||       nSt        | |      \  }}|rBt        t        |dd       |      rt        |dd	       |k7  rt        j                  d
|       y t        j                  |d	d        }t        |t               st#        d|d      |S )N)r2   r   r   r   r   neveralwaysr   r   r   zbytecode is stale for zcompiled module z is not a code object)r   _classify_pyc_impcheck_hash_based_pycs_get_pyc_sourcesource_hash_RAW_MAGIC_NUMBER_validate_hash_pyc_get_mtime_and_size_of_sourcer   r   r5   rm   marshalloadsr   
_code_typer   )r*   rM   rZ   r;   r   exc_detailsr   
hash_basedcheck_sourcesource_bytesr   source_mtimesource_sizerE   s                 r   _unmarshal_coder   G  sA   K
  --dHkJE!Jt|q(&&'1!;!;x!G*4:L'"..'99 
 $66+x> *$9 	"k  nT!BZ8,G"42;/;>++,XL9;==bc#DdJ'*8,6KLMMKr   c                 N    | j                  dd      } | j                  dd      } | S )Ns   
   
   )r   )sources    r   _normalize_line_endingsr   t  s'    ^^GU+F^^E5)FMr   c                 6    t        |      }t        || dd      S )Nrk   T)dont_inherit)r   compile)rM   r   s     r   _compile_sourcer   {  s    $V,F68V$??r   c                 z    t        j                  | dz	  dz   | dz	  dz  | dz  |dz	  |dz	  dz  |dz  dz  d	d	d	f	      S )
N	   i              ?   r   r   )r   mktime)dr   s     r   _parse_dostimer     sY    ;;	
a4	
a3	D	R	
a4	
TQ
B  r   c                     	 |dd  dv sJ |d d }| j                   |   }|d   }|d   }|d   }t        ||      |fS # t        t        t        f$ r Y yw xY w)Nr   cor         )r   r   )r&   r   r$   
IndexErrorr   )r*   r   rO   r   r   uncompressed_sizes         r   r   r     s~    BCyJ&&&CRyKK%	 ||%aLdD)+<<<j), s   9< AAc                     |dd  dv sJ |d d }	 | j                   |   }t        | j                  |      S # t        $ r Y y w xY w)Nr   r   )r&   rL   r'   r$   )r*   r   rO   s      r   r   r     s[    9
"""9D2KK%	 y11  s   5 	A Ac                    t        | |      }d }t        D ]  \  }}}||z   }t        j                  d| j                  t
        |d       	 | j                  |   }|d   }	t        | j                  |      }
d }|r	 t        | |	|||
      }nt        |	|
      }||d   }	|||	fc S  |rd| }t        ||      |t        d||      # t        $ r}|}Y d }~Ed }~ww xY w# t        $ r Y w xY w)Nztrying {}{}{}r   )	verbosityr   zmodule load failed: rU   rT   )r7   r   r5   rm   r'   r   r&   rL   r   rl   r   r$   r   )r*   r;   r   import_errorr   r   rF   rZ   rO   r>   r   rE   excrn   s                 r   rC   rC     s)   D(+DL)9 S%
I&=##OT\\8Xabc	,H-I  lGT\\95DD'*4(HdSD 'w5| lGG++/S2 (7C 84,F #5h\!BRR # '#&L'  		s*   
C"9C

	CCC"	C.-C.).r|   _frozen_importlib_externalr   r   r   _frozen_importlibr5   r   r   r   rb   r   r_   __all__r   path_separatorsr   rl   r   r#   r   re   r   r   r   _LoaderBasicsr   r   r7   r8   r4   r%   r   r   r   rL   r   r   __code__r   r   r   r   r   r   rC   r   r   r   <module>r     s3    9 E &  
  
  ]
+ ''"22126	[ 	  Cy " lO%33 lOj d+ud+	 5">{J/ : 
*(%\&P /**+

@&
2 Sr   