a Z^-xc@sRdZddlZddlmZmZddlZddlZddlZddl Z ddl Z ddl Z ddgZ ej Z ejddZGdddeZiZee ZdZd Zd ZGd ddZe d d d fe ddd fddfZddZddZddZddZdZdaddZ ddZ!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/d0d0Z,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_uint32ZipImportError zipimporterc@s eZdZdS)rN)__name__ __module__ __qualname__r r !/usr/lib64/python3.9/zipimport.pyr!sisPKic@sleZdZdZddZdddZdddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS)razipimporter(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|tsddl}||}|s,td|dtr<|tt}g}zt |}WnFt t fyt |\}}||krtd|d|}| |Yq@0|jd@dkrtd|dqq@z t|}Wn"tyt|}|t|<Yn0||_||_tj|ddd|_|jr|jt7_dS)Nrzarchive path is emptypathznot a Zip fileii) isinstanceZstrosZfsdecoder alt_path_sepreplacepath_sep_bootstrap_externalZ _path_statOSError ValueErrorZ _path_splitZappendZst_mode_zip_directory_cacheKeyError_read_directory_filesarchive _path_joinprefix)selfr rrZstZdirnameZbasenamefilesr r r __init__?s:        zzipimporter.__init__NcCsNt||}|dur|gfSt||}t||rFd|jt|gfSdgfS)afind_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_dirrr)rfullnamer mimodpathr r r find_loaderms   zzipimporter.find_loadercCs|||dS)afind_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)r&)rr#r r r r find_modules zzipimporter.find_modulecCst||\}}}|S)zget_code(fullname) -> code object. Return the code object for the specified module. Raise ZipImportError if the module couldn't be found. _get_module_coderr#code ispackager%r r r get_codeszzipimporter.get_codecCsttr|tt}|}||jtr:|t|jtd}z|j|}Wntyftdd|Yn0t |j|S)zget_data(pathname) -> string with file data. Return the data associated with 'pathname'. Raise OSError if the file wasn't found. NrZ) rrrZ startswithrlenrrr _get_data)rpathnameZkey toc_entryr r r get_datas  zzipimporter.get_datacCst||\}}}|S)zjget_filename(fullname) -> filename string. Return the filename for the specified module. r(r*r r r get_filenameszzipimporter.get_filenamecCs~t||}|dur$td||dt||}|r@t|d}n |d}z|j|}WntylYdS0t|j| S)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. Ncan't find module name __init__.py.py) r rr!rrrrr/rdecode)rr#r$r fullpathr1r r r get_sources    zzipimporter.get_sourcecCs(t||}|dur$td||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. Nr4r5)r r)rr#r$r r r is_packages zzipimporter.is_packagecCst||\}}}tj|}|dus.t|ts@t|}|tj|<||_zT|rlt||}t |j |}|g|_ t |ds|t |_ t|j||t||jWntj|=Yn0ztj|}Wn"tytd|dYn0td|||S)zload_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 {})r)sysZmodulesZgetr _module_typeZ __loader__r!rrrZ__path__Zhasattrr=Z_fix_up_moduleZ__dict__execr ImportError _bootstrap_verbose_message)rr#r+r,r%Zmodr r:r r r load_modules0     zzipimporter.load_modulecCsVz||sWdSWnty(YdS0tjsLddlm}|tdt_t||S)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)ResourceReaderT)r<r_ZipImportResourceReader _registeredZ importlib.abcrEZregister)rr#rEr r r get_resource_readers     zzipimporter.get_resource_readercCsd|jt|jdS)Nz)rrr)rr r r __repr__"zzipimporter.__repr__NrK)rrr__doc__rr&r'r-r2r3r;r<rDrHrIr r r r r-s.    &z __init__.pycTr7F)z.pycTF)r8FFcCs|j|ddS)N.)rZ rpartition)rr#r r r r!4rJr!cCs|t}||jvSrK)rr)rr Zdirpathr r r r"8sr"cCs8t||}tD]$\}}}||}||jvr|SqdSrK)r!_zip_searchorderr)rr#r suffix isbytecoder,r:r r r r As    r c Cszt|}Wn$ty2td||dYn0|z$|t d|}|t}Wn$tytd||dYn0t|tkrtd||d|ddt krz|dd|}Wn$tytd||dYn0t |t td}z|||}Wn&tyBtd||dYn0| t }|dkrjtd||d|||t}t|tkrtd||d|t||}t |d d }t |d d } ||krtd ||d|| krtd ||d||8}|| } | dkr.td||di} d} z||Wn&tyjtd||dYn0|d}t|dkrtd|dddkrqt|dkrtdt|dd} t|dd }t|d d}t|dd }t |d d }t |d d}t |dd}t|dd}t|dd}t|dd}t |dd}|||}|| krtd||d|| 7}z||}Wn&tytd||dYn0t||krtd||dz2t|||||krtd||dWn&tyFtd||dYn0| d@r\|}n4z|d}Wn$ty|dt}Yn0|dt}t||}||||||||f}|| |<| d 7} qlWdn1s0Ytd!| || S)"Nzcan't open Zip file: r rNcan't read Zip file: rznot a Zip file: zcorrupt Zip file: izbad central directory size: zbad central directory offset: z&bad central directory size or offset: i.EOF read where not expectedsPKi iii i"i*zbad local header offset: iZasciiZlatin1/rz!zipimport: found {} names in {!r})_io open_coderrseekEND_CENTRAL_DIR_SIZEZtellreadr.STRING_END_ARCHIVEZmaxMAX_COMMENT_LENZrfindrEOFErrorrr9ZUnicodeDecodeErrorZ translate cp437_tablerrrrrBrC)rfpZheader_positionbuffer file_sizeZmax_comment_startdataZpos header_sizeZ header_offsetZ arc_offsetrZcountflagscompresstimedatecrc data_size name_size extra_sizeZ comment_size file_offsetr6r tr r r r`s                          ,ru  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ cCsntrtdtddaz>zddlm}Wn$tyPtdtdYn0Wdanda0td|S)Nzzipimport: zlib UNAVAILABLE)can't decompress data; zlib not availableTr decompressFzzipimport: zlib available)_importing_zlibrBrCrZzlibru Exceptionrtr r r _get_decompress_funcs     rxc Cs|\}}}}}}}} |dkr$tdt|} z| |Wn$tydtd||dYn0| d} t| dkrtd| dddkrtd ||dt| d d } t| d d} d| | }||7}z| |Wn&tytd||dYn0| |}t||kr0td Wdn1sF0Y|dkr^|Sz t }Wnt ytd Yn0||dS)Nrznegative data sizerRr rYrVrSsPKzbad local file header: irXzzipimport: can't read datarsi) rr[r\r]rr_r.rbrrxrw)rr1ZdatapathrjrnrfrqrkrlrmrdrerorprhZraw_datarur r r r/s>     (  r/cCst||dkS)Nr)Zabs)Zt1Zt2r r r _eq_mtimeAsrycCs8||d}zt|||}Wnty0YdS0|d@dk}|r|d@dk}tjdkr|sftjdkrt||} | durttj| } zt|| ||WntyYdS0nTt ||\} } | rt t |dd| rt |dd | krt d |dSt|d d} t| ts4td |d | S) N)r6r rrrNZneverZalwaysrWrTrUzbytecode is stale for zcompiled module z is not a code object)rZ _classify_pycrA_impZcheck_hash_based_pycs_get_pyc_source source_hashZ_RAW_MAGIC_NUMBERZ_validate_hash_pyc_get_mtime_and_size_of_sourceryrrBrCmarshalZloadsr _code_type TypeError)rr0r:r#rgZ exc_detailsriZ hash_basedZ check_sourceZ source_bytesr|Z source_mtimeZ source_sizer+r r r _unmarshal_codeKsR        rcCs|dd}|dd}|S)Ns s s )r)sourcer r r _normalize_line_endings~s  rcCst|}t||dddS)Nr@T)Z dont_inherit)rZcompile)r0rr r r _compile_sourcesrc CsDt|d?d|d?d@|d@|d?|d?d@|d@dd d d f S) Ni iiii i?rNr )rkZmktime)Zdrrr r r _parse_dostimes    rc CsrzR|dddvsJ|dd}|j|}|d}|d}|d}t|||fWStttfylYdS0dS)Nr ZcZorii)rr)rrrZ IndexErrorr)rr r1rkrlZuncompressed_sizer r r r}s  r}cCsT|dddvsJ|dd}z|j|}WntyBYdS0t|j|SdS)Nr r)rrr/r)rr r1r r r r{s  r{c Cst||}tD]\}}}||}tjd|jt|ddz|j|}WntyVYq0|d}t|j|} |rt ||||| } n t || } | durq|d}| ||fSqt d||ddS)Nz trying {}{}{}rN)Z verbosityrr4r5) r!rOrBrCrrrrr/rrr) rr#r rPrQr,r:r1r%rgr+r r r r)s$    r)c@s<eZdZdZdZddZddZddZd d Zd d Z d S)rFzPrivate class used to support ZipImport.get_resource_reader(). This class is allowed to reference all the innards and private parts of the zipimporter. FcCs||_||_dSrK)rr#)rrr#r r r rsz!_ZipImportResourceReader.__init__cCsZ|jdd}|d|}ddlm}z||j|WStyTt|Yn0dS)NrMrZr)BytesIO)r#rZiorrr2rFileNotFoundError)rresourcefullname_as_pathr rr r r open_resources  z&_ZipImportResourceReader.open_resourcecCstdSrK)r)rrr r r resource_pathsz&_ZipImportResourceReader.resource_pathcCsF|jdd}|d|}z|j|Wnty@YdS0dS)NrMrZFT)r#rrr2r)rr6rr r r r is_resources z$_ZipImportResourceReader.is_resourcec csddlm}||j|j}||jj}|jdks:J|j}t }|jj D]d}z|||}Wnt yzYqNYn0|jj}t |dkr|jVqN||vrN| ||VqNdS)Nr)Pathr7)Zpathlibrrr3r#Z relative_torr6ZparentZsetrrr.Zadd) rrZ fullname_pathZ relative_pathZ package_pathZ subdirs_seenZfilenameZrelativeZ parent_namer r r contentss"       z!_ZipImportResourceReader.contentsN) rrrrLrGrrrrrr r r r rFs  rF)-rLZ_frozen_importlib_externalrrrZ_frozen_importlibrBrzr[r~r>rkZ__all__rZpath_separatorsrrArrZtyper?r^r`rarrOr!r"r rrcrvrxr/ryrZ__code__rrrrr}r{r)rFr r r r ZsX    ~. .