a
    ze-x                     @   sN  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gZejZejdd ZG dd deZi Zee	ZdZdZd	ZG d
d dZed ddfed ddfddfZdd Zdd Zdd Zdd ZdZdadd Zdd Z dd Z!d d! Z"ee"j#Z$d"d# Z%d$d% Z&d&d' Z'd(d) Z(d*d+ Z)d,d- Z*G d.d/ d/Z+dS )0    N)_unpack_uint16_unpack_uint32ZipImportErrorzipimporter   c                   @   s   e Zd ZdS )r   N)__name__
__module____qualname__ r
   r
   /usr/lib/python3.9/zipimport.pyr   !   s      s   PKi  c                   @   sh   e Zd Zdd ZdddZdddZdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd ZdS )r   c              	   C   s   t |tsdd l}||}|s,td|dtr<|tt}g }zt	|}W nF t
tfy   t|\}}||krtd|d|}|| Y q@0 |jd@ dkrtd|dqq@zt| }W n" ty   t|}|t|< Y n0 || _|| _tj|d d d  | _| jr|  jt7  _d S )Nr   zarchive path is emptypathznot a Zip filei   i   )
isinstancestrosfsdecoder   alt_path_sepreplacepath_sep_bootstrap_external
_path_statOSError
ValueError_path_splitappendst_mode_zip_directory_cacheKeyError_read_directory_filesarchive
_path_joinprefix)selfr   r   r$   stdirnamebasenamefilesr
   r
   r   __init__?   s:    

zzipimporter.__init__Nc                 C   sN   t | |}|d ur| g fS t| |}t| |rFd | j t | gfS d g fS N)_get_module_info_get_module_path_is_dirr"   r   )r%   fullnamer   mimodpathr
   r
   r   find_loaderm   s    



zzipimporter.find_loaderc                 C   s   |  ||d S )Nr   )r2   )r%   r/   r   r
   r
   r   find_module   s    	zzipimporter.find_modulec                 C   s   t | |\}}}|S r+   _get_module_coder%   r/   code	ispackager1   r
   r
   r   get_code   s    zzipimporter.get_codec                 C   st   t r|t t}|}|| jt r:|t| jt d  }z| j| }W n tyf   tdd|Y n0 t	| j|S )Nr    )
r   r   r   
startswithr"   lenr!   r   r   	_get_data)r%   pathnamekey	toc_entryr
   r
   r   get_data   s    zzipimporter.get_datac                 C   s   t | |\}}}|S r+   r4   r6   r
   r
   r   get_filename   s    zzipimporter.get_filenamec                 C   s~   t | |}|d u r$td||dt| |}|r@t|d}n
| d}z| j| }W n tyl   Y d S 0 t| j|	 S )Ncan't find module name__init__.py.py)
r,   r   r-   r   r#   r!   r   r=   r"   decode)r%   r/   r0   r   fullpathr@   r
   r
   r   
get_source   s    


zzipimporter.get_sourcec                 C   s(   t | |}|d u r$td||d|S )NrC   rD   )r,   r   )r%   r/   r0   r
   r
   r   
is_package   s    
zzipimporter.is_packagec                 C   s   t | |\}}}tj|}|d u s.t|ts@t|}|tj|< | |_zT|rlt| |}t	| j
|}|g|_t|ds|t|_t|j|| t||j W n   tj|=  Y n0 ztj| }W n" ty   td|dY n0 td|| |S )N__builtins__zLoaded module z not found in sys.moduleszimport {} # loaded from Zip {})r5   sysmodulesgetr   _module_type
__loader__r-   r   r#   r"   __path__hasattrrL   _fix_up_module__dict__execr   ImportError
_bootstrap_verbose_message)r%   r/   r7   r8   r1   modr   rI   r
   r
   r   load_module   s0    


zzipimporter.load_modulec                 C   sV   z|  |sW d S W n ty(   Y d S 0 tjsLddlm} |t dt_t| |S )Nr   )ResourceReaderT)rK   r   _ZipImportResourceReader_registeredimportlib.abcr\   register)r%   r/   r\   r
   r
   r   get_resource_reader  s    


zzipimporter.get_resource_readerc                 C   s   d| j  t | j dS )Nz<zipimporter object "z">)r"   r   r$   )r%   r
   r
   r   __repr__"  s    zzipimporter.__repr__)N)N)r   r   r	   r*   r2   r3   r9   rA   rB   rJ   rK   r[   ra   rb   r
   r
   r
   r   r   -   s   .
 

&z__init__.pycTrF   F)z.pycTF)rG   FFc                 C   s   | j |dd  S )N.   )r$   
rpartition)r%   r/   r
   r
   r   r-   4  s    r-   c                 C   s   |t  }|| jv S r+   )r   r!   )r%   r   dirpathr
   r
   r   r.   8  s    r.   c                 C   s8   t | |}tD ]$\}}}|| }|| jv r|  S qd S r+   )r-   _zip_searchorderr!   )r%   r/   r   suffix
isbytecoder8   rI   r
   r
   r   r,   A  s    


r,   c              	   C   s  zt | }W n$ ty2   td| | dY n0 | z$|t d | }|t}W n$ ty   td| | dY n0 t|tkrtd| | d|d d t	krz|dd | }W n$ ty   td| | dY n0 t
|t t d}z|| | }W n& tyB   td| | dY n0 |t	}|dk rjtd| | d|||t  }t|tkrtd| | d|t| | }t|d	d
 }t|d
d }	||k rtd| | d||	k rtd| | d||8 }||	 }
|
dk r.td| | di }d}z|| W n& tyj   td| | dY n0 |d}t|dk rtd|d d dkrqt|dkrt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 }|| | }||	krtd| | d||
7 }z||}W n& ty   td| | dY n0 t||krtd| | dz2t||| || krtd| | dW n& tyF   td| | dY n0 |d@ r\| }n4z|d}W n$ ty   |dt}Y n0 |dt}t| |}||||||||f}|||< |d 7 }qlW d    n1 s0    Y  td!||  |S )"Nzcan't open Zip file: r   rd   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   seekEND_CENTRAL_DIR_SIZEtellreadr<   STRING_END_ARCHIVEmaxMAX_COMMENT_LENrfindr   EOFErrorr   rH   UnicodeDecodeError	translatecp437_tabler   r   r   r#   rX   rY   )r"   fp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_offsetrE   r   tr
   r
   r   r    `  s    













,r    u   	
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñÑªº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ c                  C   sn   t rtd tdda z>zddlm}  W n$ tyP   td tdY n0 W da nda 0 td | S )Nzzipimport: zlib UNAVAILABLE)can't decompress data; zlib not availableTr   
decompressFzzipimport: zlib available)_importing_zlibrX   rY   r   zlibr   	Exceptionr   r
   r
   r   _get_decompress_func  s    


r   c              	   C   s  |\}}}}}}}}	|dk r$t dt| }
z|
| W n$ tyd   t d| | dY n0 |
d}t|dkrtd|d d dkrt d	| | dt|d
d }t|dd }d| | }||7 }z|
| W n& ty   t d| | dY n0 |
|}t||kr0tdW d    n1 sF0    Y  |dkr^|S z
t	 }W n t
y   t dY n0 ||dS )Nr   znegative data sizerj   r   rv   rp   rk   s   PKzbad local file header:    ru   zzipimport: can't read datar   i)r   r}   r~   r   r   r   r<   r   r   r   r   )r"   r@   datapathr   r   r   r   r   r   r   r   r   r   r   r   raw_datar   r
   r
   r   r=     s>    

(

r=   c                 C   s   t | | dkS )Nr   )abs)t1t2r
   r
   r   	_eq_mtimeA  s    r   c                 C   s8  ||d}zt |||}W n ty0   Y d S 0 |d@ dk}|r|d@ dk}tjdkr|sftjdkrt| |}	|	d urtt j|	}
zt ||
|| W n ty   Y d S 0 nTt	| |\}}|rt
t|dd |rt|dd	 |krtd
| d S t|d	d  }t|ts4td|d|S )N)rE   r   r   r   rd   neveralwaysrq   rl   rm   zbytecode is stale for zcompiled module z is not a code object)r   _classify_pycrW   _impcheck_hash_based_pycs_get_pyc_sourcesource_hash_RAW_MAGIC_NUMBER_validate_hash_pyc_get_mtime_and_size_of_sourcer   r   rX   rY   marshalloadsr   
_code_type	TypeError)r%   r>   rI   r/   r   exc_detailsr   
hash_basedcheck_sourcesource_bytesr   source_mtimesource_sizer7   r
   r
   r   _unmarshal_codeK  sR    


r   c                 C   s   |  dd} |  dd} | S )Ns   
   
   )r   )sourcer
   r
   r   _normalize_line_endings~  s    r   c                 C   s   t |}t|| dddS )NrV   T)dont_inherit)r   compile)r>   r   r
   r
   r   _compile_source  s    r   c                 C   sD   t | d? d | d? d@ | d@ |d? |d? d@ |d@ d d	d	d	f	S )
N	   i              ?   rd   r   )r   mktime)dr   r
   r
   r   _parse_dostime  s    



r   c              
   C   s^   z>|d d }| j | }|d }|d }|d }t|||fW S  tttfyX   Y dS 0 d S )Nr   r         )r   r   )r!   r   r   
IndexErrorr   )r%   r   r@   r   r   uncompressed_sizer
   r
   r   r     s    
r   c                 C   s@   |d d }z| j | }W n ty.   Y d S 0 t| j|S d S )Nr   )r!   r   r=   r"   )r%   r   r@   r
   r
   r   r     s    r   c              	   C   s   t | |}tD ]\}}}|| }tjd| jt|dd z| j| }W n tyV   Y q0 |d }t| j|}	|rt	| ||||	}
n
t
||	}
|
d u rq|d }|
||f  S qtd||dd S )Nztrying {}{}{}rd   )	verbosityr   rC   rD   )r-   rg   rX   rY   r"   r   r!   r   r=   r   r   r   )r%   r/   r   rh   ri   r8   rI   r@   r1   r   r7   r
   r
   r   r5     s$    

r5   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )r]   Fc                 C   s   || _ || _d S r+   )r   r/   )r%   r   r/   r
   r
   r   r*     s    z!_ZipImportResourceReader.__init__c                 C   sZ   | j dd}| d| }ddlm} z|| j|W S  tyT   t|Y n0 d S )Nrc   r|   r   )BytesIO)r/   r   ior   r   rA   r   FileNotFoundError)r%   resourcefullname_as_pathr   r   r
   r
   r   open_resource  s    z&_ZipImportResourceReader.open_resourcec                 C   s   t d S r+   )r   )r%   r   r
   r
   r   resource_path  s    z&_ZipImportResourceReader.resource_pathc                 C   sF   | j dd}| d| }z| j| W n ty@   Y dS 0 dS )Nrc   r|   FT)r/   r   r   rA   r   )r%   rE   r   r   r
   r
   r   is_resource  s    z$_ZipImportResourceReader.is_resourcec           	   	   c   s   ddl m} || j| j}|| jj}|j}t }| jj	D ]d}z|||}W n t
yl   Y q@Y n0 |jj}t|dkr|jV  q@||vr@|| |V  q@d S )Nr   )Path)pathlibr   r   rB   r/   relative_tor"   parentsetr!   r   rE   r<   add)	r%   r   fullname_pathrelative_pathpackage_pathsubdirs_seenfilenamerelativeparent_namer
   r
   r   contents  s     


z!_ZipImportResourceReader.contentsN)	r   r   r	   r^   r*   r   r   r   r   r
   r
   r
   r   r]     s   	r]   ),_frozen_importlib_externalr   r   r   _frozen_importlibrX   r   r}   r   rM   r   __all__r   path_separatorsr   rW   r   r   typerP   r   r   r   r   rg   r-   r.   r,   r    r   r   r   r=   r   r   __code__r   r   r   r   r   r   r5   r]   r
   r
   r
   r   <module>   sV     		~.
.
