o ?Ogx@sPdZddlZddlmZmZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddgZ ejZejddZGdddeZiZee ZdZd Zd ZGd ddejZed d d feddd fddfZddZddZddZddZdZ da!ddZ"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-dS)/aPzipimport 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 0/opt/alt/python310/lib64/python3.10/zipimport.pyr"ssPKic@s~eZdZdZddZdddZdddZdd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)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}||}|std|dtr|tt}g} zt |}Wn#t t fyKt |\}}||krBtd|d|}| |Ynw|jd@dkrYtd|dnq!zt|}Wntyrt|}|t|<Ynw||_||_tj|ddd|_|jr|jt7_dSdS) Nrzarchive path is emptypathTznot a Zip fileii) isinstancestrosfsdecoder alt_path_sepreplacepath_sep_bootstrap_external _path_statOSError ValueError _path_splitappendst_mode_zip_directory_cacheKeyError_read_directory_filesarchive _path_joinprefix)selfrrr$stdirnamebasenamefilesr r r __init__@sD         zzipimporter.__init__NcCsZtdtt||}|dur|gfSt||}t||r)d|jt|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. Deprecated since Python 3.10. Use find_spec() instead. zfzipimporter.find_loader() is deprecated and slated for removal in Python 3.12; use find_spec() insteadN) _warningswarnDeprecationWarning_get_module_info_get_module_path_is_dirr"r)r%fullnamermimodpathr r r find_loaderns    zzipimporter.find_loadercCstdt|||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. Deprecated since Python 3.10. Use find_spec() instead. zfzipimporter.find_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadr)r+r,r-r4)r%r1rr r r find_modules zzipimporter.find_modulecCslt||}|durtj|||dSt||}t||r4|jt|}tj|ddd}|j ||SdS)zkCreate a ModuleSpec for the specified module. Returns None if the module cannot be found. N) is_packageT)nameloaderr6) r. _bootstrapspec_from_loaderr/r0r"r ModuleSpecsubmodule_search_locationsr)r%r1target module_infor3rspecr r r find_specs    zzipimporter.find_speccCst||\}}}|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_coder%r1code ispackager3r r r get_codeszzipimporter.get_codecCsptr|tt}|}||jtr|t|jtd}z|j|}Wn ty1tdd|wt |j|S)zget_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%pathnamekey toc_entryr r r get_datas    zzipimporter.get_datacCst||\}}}|S)zget_filename(fullname) -> filename string. Return the filename for the specified module or raise ZipImportError if it couldn't be imported. rArCr r r get_filenameszzipimporter.get_filenamecCs~t||}|durtd||dt||}|r t|d}n|d}z|j|}Wn ty6YdSwt|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 r7 __init__.py.py) r.rr/rr#r!rrJr"decode)r%r1r2rfullpathrMr r r get_sources    zzipimporter.get_sourcecCs(t||}|durtd||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. NrPrQ)r.r)r%r1r2r r r r6s zzipimporter.is_packagec Csd}t|tt||\}}}tj|}|dust|ts(t|}|tj|<||_ z*|r>t ||}t |j |}|g|_t|dsFt|_t |j||t||jWntj|=ztj|}Wntyttd|dwtd|||S)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() insteadN __builtins__zLoaded module z not found in sys.moduleszimport {} # loaded from Zip {})r+r,r-rBsysmodulesgetr _module_type __loader__r/rr#r"__path__hasattrrW_fix_up_module__dict__execr ImportErrorr9_verbose_message) r%r1msgrDrEr3modrrUr r r load_modules6      zzipimporter.load_modulecCs@z ||s WdSWn tyYdSwddlm}|||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) ZipReader)r6rimportlib.readersrg)r%r1rgr r r get_resource_reader;s    zzipimporter.get_resource_readercCsHzt|j|_|jt|j<WdSty#t|jdi|_YdSw)z)Reload the file data of the archive path.N)r r"r!rrpopr%r r r invalidate_cachesJs   zzipimporter.invalidate_cachescCsd|jt|jdS)Nz)r"rr$rkr r r __repr__Tszzipimporter.__repr__N)rrr __doc__r*r4r5r@rFrNrOrVr6rfrirlrmr r r r r.s . %    + z __init__.pycTrRF)z.pycTF)rSFFcCs|j|ddS)N.)r$ rpartition)r%r1r r r r/fsr/cCs|t}||jvSrn)rr!)r%rdirpathr r r r0js r0cCs8t||}tD]\}}}||}||jvr|SqdSrn)r/_zip_searchorderr!)r%r1rsuffix isbytecoderErUr r r r.ss  r.c Cszt|}Wntytd||dw|T|}z@z|t d|}|t}WntyDtd||dwt|tkrTtd||d|ddt krz |dd|}Wntyxtd||dwt |t td}z |||}Wntytd||dw| t }|dkrtd||d|||t}t|tkrtd||d|t||}t |d d } t |d d } || krtd ||d|| krtd ||d|| 8}|| } | dkrtd||di} d} z||Wnty+td||dw |d}t|dkr=td|dddkrHnt|dkrStdt|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||}Wntytd||dwt||krtd||dzt|| || |krtd||dWntytd||dw|d@r!|}nz|d}Wnty:|dt}Ynw|d t}t||}||||||||f}|| |<| d!7} q-W||n||wWdn 1sswYtd"| || S)#Nzcan't open Zip file: r rqcan'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: T.EOF read where not expectedsPK  "*zbad local header offset: iasciilatin1/rz!zipimport: found {} names in {!r})_io open_coderrtellseekEND_CENTRAL_DIR_SIZEreadrISTRING_END_ARCHIVEmaxMAX_COMMENT_LENrfindrEOFErrorrrTUnicodeDecodeError translate cp437_tablerrrr#r9rc)r"fp start_offsetheader_positionbuffer file_sizemax_comment_startdatapos header_size header_offset arc_offsetr)countflagscompresstimedatecrc data_size name_size extra_size comment_size file_offsetr7rtr r r r s                       2tr u  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ cCsjtr tdtddazzddlm}Wnty&tdtdwWdandawtd|S)Nzzipimport: zlib UNAVAILABLE)can't decompress data; zlib not availableTr decompressFzzipimport: zlib available)_importing_zlibr9rcrzlibr Exceptionrr r r _get_decompress_func7s     rc Csx|\}}}}}}}} |dkrtdt|} z| |Wnty/td||dw| d} t| dkr?td| dddkrPtd ||dt| d d } t| d d} d| | }||7}z| |Wntytd||dw| |}t||krtd Wdn1swY|dkr|Szt }Wn t ytd w||dS)Nrznegative data sizerwr rr}rxsPKzbad local file header: rzzipimport: can't read datari) rrrrrrrIrrrr)r"rMdatapathrrrrrrrrrrrrraw_datarr r r rJLsH           rJcCst||dkS)Nr)abs)t1t2r r r _eq_mtimezsrcCs||d}t|||}|d@dk}|r?|d@dk}tjdkr>|s&tjdkr>t||} | dur>ttj| } t|| ||n(t||\} } | rgt t |dd| r]t |dd | krgt d |dSt |d d} t| ts}td |d | S) N)r7rrrrqneveralwaysr~ryrzzbytecode is stale for zcompiled module z is not a code object)r _classify_pyc_impcheck_hash_based_pycs_get_pyc_source source_hash_RAW_MAGIC_NUMBER_validate_hash_pyc_get_mtime_and_size_of_sourcerrr9rcmarshalloadsr _code_type TypeError)r%rKrUr1r exc_detailsr hash_based check_source source_bytesr source_mtime source_sizerDr r r _unmarshal_codesD      rcCs|dd}|dd}|S)Ns   )r)sourcer r r _normalize_line_endingss  rcCst|}t||dddS)NraT) dont_inherit)rcompile)rKrr r r _compile_sourcesrc CsDt|d?d|d?d@|d@|d?|d?d@|d@dd d d f S) N i ?rqr)rmktime)drr r r _parse_dostimes    rc Csnz)|dddvs J|dd}|j|}|d}|d}|d}t|||fWStttfy6YdSw)Nrcor)rr)r!rr IndexErrorr)r%rrMrruncompressed_sizer r r rs  rcCsP|dddvs J|dd}z|j|}Wn ty!YdSwt|j|S)Nrr)r!rrJr")r%rrMr r r rs   rc Cst||}d}tD]f\}}}||}tjd|jt|ddz|j|}Wn ty-Yq w|d} t|j|} d} |r[z t || ||| } Wnt yZ} z| }WYd} ~ n d} ~ wwt | | } | dureq |d} | || fS|r~d|} t | |d|t d||d)Nz trying {}{}{}rq) verbosityrzmodule load failed: rQrP) r/rtr9rcr"rr!rrJrrbrr)r%r1r import_errorrurvrErUrMr3rrDexcrdr r r rBs:     rB).ro_frozen_importlib_externalrrr_frozen_importlibr9rrrrXrr+__all__rpath_separatorsrrbrrtyper[rrr _LoaderBasicsrrtr/r0r.r rrrrJrr__code__rrrrrrrBr r r r s\ 2   . (