U e5d-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.8/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  |¡}WnHt t fk r–t  |¡\}}||kr„td|d�‚|}|  |¡Yq@X|jd@dkr¶td|d�‚q¶q@z t|}Wn$tk ræt|ƒ}|t|<YnX||_||_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||ƒ}|dk r|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_codecCsvtr| tt¡}|}| |jt¡r:|t|jtƒd…}z|j|}Wn tk rhtdd|ƒ‚YnXt |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||ƒ}|dkr$td|›�|d�‚t||ƒ}|r@t |d¡}n |›d�}z|j|}Wntk rnYdSXt|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||ƒ}|dkr$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 |¡}|dks.t|tƒs@t|ƒ}|tj|<||_zT|rlt||ƒ}t  |j |¡}|g|_ t |dƒs|t |_ t |j||¡t||jƒWntj|=‚YnXztj|}Wn$tk rätd|›d�ƒ‚YnXt 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_modulecCsXz| |¡sWdSWntk r*YdSXtjsNddlm}| 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}||jkS©N)rr!)r%rÚdirpathr r r r-8sr-cCs8t||ƒ}tD]$\}}}||}||jkr|SqdSrf)r,Ú_zip_searchorderr!)r%r.rÚsuffixÚ isbytecoder7rHr r r r+As    r+c Csüzt |¡}Wn&tk r4td|›�|d�‚YnX|��¨z$| t d¡| ¡}| t¡}Wn&tk rˆtd|›�|d�‚YnXt|ƒtkr¨td|›�|d�‚|dd…t k�r²z| dd¡| ¡}Wn&tk røtd|›�|d�‚YnXt |t tdƒ}z| |¡| ¡}Wn(tk �rJtd|›�|d�‚YnX|  t ¡}|dk�rrtd|›�|d�‚|||t…}t|ƒtk�r¢td|›�|d�‚|t|ƒ|}t |d d …ƒ}t |d d …ƒ} ||k�rîtd |›�|d�‚|| k�r td |›�|d�‚||8}|| } | dk�r6td|›�|d�‚i} d} z| |¡Wn(tk �rttd|›�|d�‚YnX| 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(tk �rØtd|›�|d�‚YnXt|ƒ|k�rútd|›�|d�‚z2t| ||¡ƒ||k�r*td|›�|d�‚Wn(tk �rTtd|›�|d�‚YnX| d@�rj| ¡}n6z| d¡}Wn&tk �rž| d¡ t¡}YnX| dt¡}t ||¡}||||||||f}|| |<| d 7} �qvW5QRXt 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{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿âŒ�¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗â•�╜╛â”�└┴┬├─┼╞╟╚╔╩╦╠â•�╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌â–�▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√â�¿Â²â– Â cCsltrt d¡tdƒ‚daz      r<cCst||ƒdkS)Nr)Úabs)Út1Út2r r r Ú _eq_mtimeAsr¯cCs<||dœ}zt |||¡}Wntk r2YdSX|d@dk}|r¶|d@dk}tjdkr´|shtjdkr´t||ƒ} | dk r´t tj| ¡} zt || ||¡Wntk r²YdSXnTt ||ƒ\} } | �r t t |dd…ƒ| ƒröt |dd …ƒ| k�r t   d |›�¡dSt |d d…¡} t| tƒ�s8td |›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_codeKsXþ   ÿÿ þÿ ÿÿÿ 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 CstzR|dd…dkst‚|dd…}|j|}|d}|d}|d}t||ƒ|fWStttfk rnYdSXdS)Nr©ÚcÚorÍéé)rr)ÚAssertionErrorr!rÔrÚ IndexErrorr½)r%rr?r™ršÚuncompressed_sizer r r r¹˜s  r¹cCsV|dd…dkst‚|dd…}z|j|}Wntk rDYdSXt|j|ƒSdS)NrrÕ)rÚr!rr<r")r%rr?r r r rµ«s rµc CsÆt||ƒ}tD] \}}}||}tjd|jt|dd�z|j|}Wntk rXYqX|d}t|j|ƒ} |r„t ||||| ƒ} n t || ƒ} | dkr˜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__cCs\|j dd¡}|›d|›�}ddlm}z||j |¡ƒWStk rVt|ƒ‚YnXdS)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_pathcCsH|j dd¡}|›d|›�}z|j |¡Wntk rBYdSXdS)Nrcr}FT)r.rrr@r)r%rDrârr r r Ú is_resourceïsz$_ZipImportResourceReader.is_resourcec csºddlm}||j |j¡ƒ}| |jj¡}|jdks:t‚|j }t ƒ}|jj D]f}z||ƒ |¡}Wnt k r|YqNYnX|j j}t |ƒdkrœ|jVqN||krN| |¡|VqNdS)Nr)ÚPathrE)ÚpathlibrærrAr.Ú relative_tor"rDrÚÚparentÚsetr!rr;Ú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  ü  ~þ. .