a �DOg-x�@sRdZddlZddlmZmZddlZddlZddlZddl Z ddl Z ddl Z ddgZ ej Z ejdd�ZGdd�de�ZiZee �ZdZd Zd ZGd d�d�Ze d d d fe ddd fddfZdd�Zdd�Zdd�Zdd�ZdZdadd�Z dd�Z!dd �Z"d!d"�Z#ee#j$�Z%d#d$�Z&d%d&�Z'd'd(�Z(d)d*�Z)d+d,�Z*d-d.�Z+Gd/d0�d0�Z,dS)1aPzipimport 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@s eZdZdS)rN)�__name__� __module__� __qualname__�r r �!/usr/lib64/python3.9/zipimport.pyr!s�sPKi��c@sleZdZdZdd�Zddd�Zddd�Zd d �Zd d �Zd d�Z dd�Z dd�Z dd�Z dd�Z dd�ZdS)ra�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 Cs t|t�sddl}|�|�}|s,td|d��tr<|�tt�}g}zt� |�}WnFt t fy�t� |�\}}||kr�td|d��|}|� |�Yq@0|jd@dkr�td|d��q�q@z t|}Wn"ty�t|�}|t|<Yn0||_||_tj|ddd��|_|j�r|jt7_dS)Nrzarchive path is empty��pathznot 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)�selfrrr$�st�dirname�basename�filesr r r �__init__?s:        zzipimporter.__init__NcCsNt||�}|dur|gfSt||�}t||�rFd|j�t�|��gfSdgfS)a�find_loader(fullname, path=None) -> self, str or None. Search for a module specified by 'fullname'. 'fullname' must be the fully qualified (dotted) module name. It returns the zipimporter instance itself if the module was found, a string containing the full path name if it's possibly a portion of a namespace package, or None otherwise. The optional 'path' argument is ignored -- it's there for compatibility with the importer protocol. N)�_get_module_info�_get_module_path�_is_dirr"r)r%�fullnamer�mi�modpathr r r � find_loaderms   zzipimporter.find_loadercCs|�||�dS)a�find_module(fullname, path=None) -> self or None. Search for a module specified by 'fullname'. 'fullname' must be the fully qualified (dotted) module name. It returns the zipimporter instance itself if the module was found, or None if it wasn't. The optional 'path' argument is ignored -- it's there for compatibility with the importer protocol. r)r1)r%r.rr r r � find_module�s zzipimporter.find_modulecCst||�\}}}|S)z�get_code(fullname) -> code object. Return the code object for the specified module. Raise ZipImportError if the module couldn't be found. ��_get_module_code�r%r.�code� ispackager0r r r �get_code�szzipimporter.get_codecCsttr|�tt�}|}|�|jt�r:|t|jt�d�}z|j|}Wntyftdd|��Yn0t |j|�S)z�get_data(pathname) -> string with file data. Return the data associated with 'pathname'. Raise OSError if the file wasn't found. Nr�) rrr� startswithr"�lenr!rr� _get_data)r%�pathname�key� toc_entryr r r �get_data�s  zzipimporter.get_datacCst||�\}}}|S)zjget_filename(fullname) -> filename string. Return the filename for the specified module. r3r5r r r � get_filename�szzipimporter.get_filenamecCs~t||�}|dur$td|��|d��t||�}|r@t�|d�}n |�d�}z|j|}WntylYdS0t|j|�� �S)z�get_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 ��name� __init__.py�.py) r+rr,rr#r!rr<r"�decode)r%r.r/r�fullpathr?r r r � get_source�s    zzipimporter.get_sourcecCs(t||�}|dur$td|��|d��|S)z�is_package(fullname) -> bool. Return True if the module specified by fullname is a package. Raise ZipImportError if the module couldn't be found. NrBrC)r+r)r%r.r/r r r � is_package�s zzipimporter.is_packagecCs�t||�\}}}tj�|�}|dus.t|t�s@t|�}|tj|<||_zT|rlt||�}t� |j |�}|g|_ t |d�s|t |_ t�|j||�t||j�Wntj|=�Yn0ztj|}Wn"ty�td|�d���Yn0t�d||�|S)z�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 wasn't found. N� __builtins__zLoaded module z not found in sys.moduleszimport {} # loaded from Zip {})r4�sys�modules�getr� _module_type� __loader__r,rr#r"�__path__�hasattrrK�_fix_up_module�__dict__�execr� ImportError� _bootstrap�_verbose_message)r%r.r6r7r0�modrrHr r r � load_module�s0     zzipimporter.load_modulecCsVz|�|�sWdSWnty(YdS0tjsLddlm}|�t�dt_t||�S)z�Return 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)�ResourceReaderT)rJr�_ZipImportResourceReader� _registered� importlib.abcr[�register)r%r.r[r r r �get_resource_readers     zzipimporter.get_resource_readercCsd|j�t�|j�d�S)Nz)r"rr$)r%r r r �__repr__"szzipimporter.__repr__)N)N)rrr �__doc__r*r1r2r8r@rArIrJrZr`rar r r r r-s.    &z __init__.pycTrEF)z.pycTF)rFFFcCs|j|�d�dS)N�.�)r$� rpartition)r%r.r r r r,4sr,cCs|t}||jvS�N)rr!)r%r�dirpathr r r r-8sr-cCs8t||�}tD]$\}}}||}||jvr|SqdSrf)r,�_zip_searchorderr!)r%r.r�suffix� isbytecoder7rHr r r r+As    r+c Cszt�|�}Wn$ty2td|��|d��Yn0|���z$|�t d�|��}|�t�}Wn$ty�td|��|d��Yn0t|�tkr�td|��|d��|dd�t k�r�z|�dd�|��}Wn$ty�td|��|d��Yn0t |t td�}z|�|�|��}Wn&t�yBtd|��|d��Yn0|� t �}|dk�rjtd|��|d��|||t�}t|�tk�r�td|��|d��|t|�|}t |d d ��}t |d d ��} ||k�r�td |��|d��|| k�rtd |��|d��||8}|| } | dk�r.td|��|d��i} d} z|�|�Wn&t�yjtd|��|d��Yn0|�d�}t|�dk�r�td��|dd�dk�r��q�t|�dk�r�td��t|dd��} t|dd ��}t|d d��}t|dd ��}t |d d ��}t |d d��}t |dd��}t|dd��}t|dd��}t|dd��}t |dd��}|||}|| k�r�td|��|d��|| 7}z|�|�}Wn&t�y�td|��|d��Yn0t|�|k�r�td|��|d��z2t|�||��||k�rtd|��|d��Wn&t�yFtd|��|d��Yn0| d@�r\|��}n4z|�d�}Wn$t�y�|�d��t�}Yn0|�dt�}t�||�}||||||||f}|| |<| d 7} �qlWd�n1�s�0Yt�d!| |�| S)"Nzcan't open Zip file: r rd�can't read Zip file: �rznot a Zip file: zcorrupt Zip file: � ��zbad central directory size: zbad central directory offset: z&bad central directory size or offset: �.�EOF read where not expectedsPK�� ����� �"�*zbad local header offset: i�ascii�latin1�/rz!zipimport: found {} names in {!r})�_io� open_coderr�seek�END_CENTRAL_DIR_SIZE�tell�readr;�STRING_END_ARCHIVE�max�MAX_COMMENT_LEN�rfindr�EOFErrorrrG�UnicodeDecodeError� translate� cp437_tablerrrr#rWrX)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_offsetrDr�tr r r r `s�       � ��   �    � �          ,r u�  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ cCsntrt�d�td��daz>zddlm}Wn$tyPt�d�td��Yn0Wdanda0t�d�|S)Nzzipimport: zlib UNAVAILABLE�)can't decompress data; zlib not availableTr�� decompressFzzipimport: zlib available)�_importing_zlibrWrXr�zlibr�� Exceptionr�r r r �_get_decompress_func�s     r�c Cs�|\}}}}}}}} |dkr$td��t�|���} z| �|�Wn$tydtd|��|d��Yn0| �d�} t| �dkr�td��| dd�dkr�td |��|d��t| d d ��} t| d d��} d| | }||7}z| �|�Wn&t�ytd|��|d��Yn0| �|�}t|�|k�r0td ��Wd�n1�sF0Y|dk�r^|Sz t �}Wnt �y�td ��Yn0||d�S)Nrznegative data sizerkr rwrqrlsPKzbad local file header: �rvzzipimport: can't read datar�i����) rr~rr�rr�r;r�rr�r�)r"r?�datapathr�r�r�r�r�r�r�r�r�r�r�r��raw_datar�r r r r<s>     (  r<cCst||�dkS)Nr)�abs)�t1�t2r r r � _eq_mtimeAsr�cCs8||d�}zt�|||�}Wnty0YdS0|d@dk}|r�|d@dk}tjdkr�|sftjdkr�t||�} | dur�t�tj| �} zt�|| ||�Wnty�YdS0nTt ||�\} } | �rt t |dd��| �r�t |dd ��| k�rt � d |���dSt�|d d��} t| t��s4td |�d ���| S) N)rDrrrrd�never�alwaysrrrmrnzbytecode is stale for zcompiled module z is not a code object)r� _classify_pycrV�_imp�check_hash_based_pycs�_get_pyc_source� source_hash�_RAW_MAGIC_NUMBER�_validate_hash_pyc�_get_mtime_and_size_of_sourcer�rrWrX�marshal�loadsr� _code_type� TypeError)r%r=rHr.r�� exc_detailsr�� hash_based� check_source� source_bytesr�� source_mtime� source_sizer6r r r �_unmarshal_codeKsR�    �� ��  ��� r�cCs|�dd�}|�dd�}|S)Ns � � )r)�sourcer r r �_normalize_line_endings~s  r�cCst|�}t||ddd�S)NrUT)� dont_inherit)r��compile)r=r�r r r �_compile_source�sr�c CsDt�|d?d|d?d@|d@|d?|d?d@|d@dd d d f �S) N� i����� �?rdr)r��mktime)�dr�r r r �_parse_dostime�s    �r�c Cs^z>|dd�}|j|}|d}|d}|d}t||�|fWStttfyXYdS0dS)Nrr���)rr)r!r�r� IndexErrorr�)r%rr?r�r��uncompressed_sizer r r r��s  r�cCs@|dd�}z|j|}Wnty.YdS0t|j|�SdS)Nr)r!rr<r")r%rr?r r r r��s   r�c Cs�t||�}tD]�\}}}||}tjd|jt|dd�z|j|}WntyVYq0|d}t|j|�} |r�t ||||| �} n t || �} | dur�q|d}| ||fSqt d|��|d��dS)Nz trying {}{}{}rd)� verbosityrrBrC) r,rhrWrXr"rr!rr<r�r�r) r%r.rrirjr7rHr?r0r�r6r r r r4�s$    r4c@s<eZdZdZdZdd�Zdd�Zdd�Zd d �Zd d �Z d S)r\z�Private class used to support ZipImport.get_resource_reader(). This class is allowed to reference all the innards and private parts of the zipimporter. FcCs||_||_dSrf)rr.)r%rr.r r r r*�sz!_ZipImportResourceReader.__init__cCsZ|j�dd�}|�d|��}ddlm}z||j�|��WStyTt|��Yn0dS)Nrcr}r)�BytesIO)r.r�ior�rr@r�FileNotFoundError)r%�resource�fullname_as_pathrr�r r r � open_resource�s  z&_ZipImportResourceReader.open_resourcecCst�dSrf)r�)r%r�r r r � resource_path�sz&_ZipImportResourceReader.resource_pathcCsF|j�dd�}|�d|��}z|j�|�Wnty@YdS0dS)Nrcr}FT)r.rrr@r)r%rDr�rr r r � is_resource�s z$_ZipImportResourceReader.is_resourcec cs�ddlm}||j�|j��}|�|jj�}|j}t�}|jj D]d}z||��|�}Wnt ylYq@Yn0|jj }t |�dkr�|j Vq@||vr@|� |�|Vq@dS)Nr)�Path)�pathlibr�rrAr.� relative_tor"�parent�setr!rrDr;�add) r%r�� fullname_path� relative_path� package_path� subdirs_seen�filename�relative� parent_namer r r �contents�s        z!_ZipImportResourceReader.contentsN) rrr rbr]r*r�r�r�r�r r r r r\�s  r\)-rb�_frozen_importlib_externalrrr�_frozen_importlibrWr�r~r�rLr��__all__r�path_separatorsrrVrr�typerOr�r�r�rrhr,r-r+r r�r�r�r<r�r��__code__r�r�r�r�r�r�r4r\r r r r �sX  �  ~�. .