o ?OgR@sdZdaddlZddlZddlZddlZddlZejdkZer(ddl Z ddl Z nddl Z er3ddgZ ndgZ edde DsAJe dZee Zde Z d d e DZd Zd ZeeZd dZeZddZddZddZerwddZnddZddZddZddZddZ d d!Z!erd"d#Z"nd$d#Z"dpd&d'Z#e$e#j%Z&d('d)d*d+Z(e)*e(d*Z+d,Z,d-Z-d.gZ.ere./d/e0Z1d0gZ2e2Z3Z4dqdd1d2d3Z5d4d5Z6d6d7Z7d8d9Z8d:d;Z9dd?Z;d@dAZdrdFdGZ?dsdHdIZ@dtdKdLZAdMdNZBeCZDdqdeDdOdPdQZEGdRdSdSZFGdTdUdUZGGdVdWdWeGZHGdXdYdYZIGdZd[d[eIeHZJGd\d]d]eIeGZKGd^d_d_eIeGZLGd`dadaZMGdbdcdcZNGdddedeZOGdfdgdgZPdqdhdiZQdjdkZRdldmZSdndoZTdS)ua^Core implementation of path-based import. This module is NOT meant to be directly imported! It has been designed such that it can be bootstrapped into Python as the implementation of import. As such it requires the injection of specific modules and attributes in order to work. One should use importlib as the public-facing version of this module. NZwin32\/ccs|] }t|dkVqdS)N)len).0seprD/opt/alt/python310/lib64/python3.10/importlib/_bootstrap_external.py .sr cCsh|]}d|qS):r)rsrrr 2sr)win)cygwindarwincs>tjtrtjtrdndfdd}|Sdd}|S)N PYTHONCASEOKs PYTHONCASEOKcstjj o tjvS)z^True if filenames must be checked case-insensitively and ignore environment flags are not set.)sysflagsignore_environment_osenvironrkeyrr _relax_caseCz%_make_relax_case.._relax_casecSdS)z5True if filenames must be checked case-insensitively.Frrrrr rG)rplatform startswith_CASE_INSENSITIVE_PLATFORMS#_CASE_INSENSITIVE_PLATFORMS_STR_KEY)rrrr _make_relax_case<s   r"cCst|d@ddS)z*Convert a 32-bit integer to little-endian.little)intto_bytes)xrrr _pack_uint32Orr)cCt|dksJt|dS)z/Convert 4 bytes in little-endian to an integer.r$r%rr& from_bytesdatarrr _unpack_uint32T r/cCr*)z/Convert 2 bytes in little-endian to an integer.r%r+r-rrr _unpack_uint16Yr0r2cGs|sdSt|dkr|dSd}g}ttj|D]=\}}|ts&|tr3|tp,|}t |g}q|drL| | krF|}|g}q| |q|pO|}| |qdd|D}t|dkrk|dsk|t S|t |S)Replacement for os.path.join().r rrr cSg|] }|r|tqSrrstrippath_separatorsrprrr ws_path_join..) rmapr_path_splitrootrpath_sep_tupleendswithr6r7path_sepcasefoldappendjoin) path_partsrootpathZnew_roottailrrr _path_join`s*     rHcGstdd|DS)r3cSr4rr5)rpartrrr r:sr;)r@rC)rDrrr rH~s csBtfddtD}|dkrdfSd||ddfS)z Replacement for os.path.split().c3s|]}|VqdSN)rfindr8rFrr r sz_path_split..rr Nr)maxr7)rFirrLr _path_splitsrOcCs t|S)z~Stat the path. Made a separate function to make it easier to override in experiments (e.g. cache stat results). )rstatrLrrr _path_stats rQcCs0zt|}Wn tyYdSw|jd@|kS)z1Test whether the path is the specified mode type.Fi)rQOSErrorst_mode)rFmode stat_inforrr _path_is_mode_types   rVcCs t|dS)zReplacement for os.path.isfile.i)rVrLrrr _path_isfile rWcCs|st}t|dS)zReplacement for os.path.isdir.i@)rgetcwdrVrLrrr _path_isdirs rZcCs>|sdSt|ddd}t|dko|dp|dS)Replacement for os.path.isabs.Frrrrz\\)rr=replacerrr?)rFrErrr _path_isabss r]cCs |tS)r[)rr7rLrrr r]rXc Csd|t|}t|tjtjBtjB|d@}z$t|d }| |Wdn1s/wYt ||WdSt yTzt |Wt ySYww)zBest-effort function to write data to a path atomically. Be prepared to handle a FileExistsError if concurrent writing of the temporary file is attempted.{}.{}r^wbN) formatidropenO_EXCLO_CREATO_WRONLY_ioFileIOwriter\rRunlink)rFr.rTpath_tmpfdfilerrr _write_atomics$    rnio r1r%s __pycache__zopt-z.pyz.pywz.pyc) optimizationc CsP|durtdt|durd}t||rdnd}t|}t|\}}|d\}}}tj j } | dur9t dd |r?|n||| g} |durVtj jdkrRd}ntj j}t|}|dkrp|sitd |d | t|} | td} tjdurt|stt|}|dd kr|dtvr|d d}ttj|t| St|t| S) aGiven the path to a .py file, return the path to its .pyc file. The .py file does not need to exist; this simply returns the path to the .pyc file calculated as if the .py file were imported. The 'optimization' parameter controls the presumed optimization level of the bytecode file. If 'optimization' is not None, the string representation of the argument is taken and verified to be alphanumeric (else ValueError is raised). The debug_override parameter is deprecated. If debug_override is not None, a True value is the same as setting 'optimization' to the empty string while a False value is equivalent to setting 'optimization' to '1'. If sys.implementation.cache_tag is None then NotImplementedError is raised. NzFthe debug_override parameter is deprecated; use 'optimization' insteadz2debug_override or optimization must be set to Noner r.$sys.implementation.cache_tag is Nonerz{!r} is not alphanumericz{}.{}{}r r1) _warningswarnDeprecationWarning TypeErrorrfspathrO rpartitionrimplementation cache_tagNotImplementedErrorrCroptimizestrisalnum ValueErrorra_OPTBYTECODE_SUFFIXESpycache_prefixr]rHrYr7lstrip_PYCACHE) rFdebug_overriderpmessageheadrGbaserresttagalmost_filenamefilenamerrr cache_from_source|sH         rc Cs(tjjdur tdt|}t|\}}d}tjdur3tjt }| |t r3|t |d}d}|sHt|\}}|t krHtt d||d}|dvrXtd||d kr|dd d }| tsptd t|t td}|std |d|dd} t|| tdS)anGiven the path to a .pyc. file, return the path to its .py file. The .pyc file does not need to exist; this simply returns the path to the .py file calculated to correspond to the .pyc file. If path does not conform to PEP 3147/488 format, ValueError will be raised. If sys.implementation.cache_tag is None then NotImplementedError is raised. NrrFTz not bottom-level directory in rq>r1zexpected only 2 or 3 dots in rr1z5optimization portion of filename does not start with zoptimization level z is not an alphanumeric valuer)rryrzr{rrwrOrr6r7rr@rrrcountrsplitrr~ partitionrHSOURCE_SUFFIXES) rFrpycache_filenamefound_in_pycache_prefix stripped_pathpycache dot_countrp opt_level base_filenamerrr source_from_caches<        rc Cs|t|dkrdS|d\}}}|r|dddkr|Szt|}Wnttfy5|dd}Ynwt|r<|S|S)zConvert a bytecode file path to a source path (if possible). This function exists purely for backwards-compatibility for PyImport_ExecCodeModuleWithFilenames() in the C API. rNrqpy)rrxlowerrr{rrW) bytecode_pathr_ extension source_pathrrr _get_sourcefiles  rcCsD|ttrzt|WStyYdSw|ttr |SdSrJ)r?tuplerrr{r)rrrr _get_cacheds  rcCs2zt|j}Wn tyd}Ynw|dO}|S)z3Calculate the mode permissions for a bytecode file.r^)rQrSrR)rFrTrrr _calc_mode s rcs4dfdd }tdurtj}ndd}|||S)zDecorator to verify that the module being requested matches the one the loader can handle. The first argument (self) must define _name which the second argument is compared against. If the comparison fails then ImportError is raised. NcsH|dur|j}n|j|krtd|j|f|d||g|Ri|S)Nzloader for %s cannot handle %sname)r ImportError)selfrargskwargsmethodrr _check_name_wrappers z(_check_name.._check_name_wrappercSs8dD]}t||rt||t||q|j|jdS)N) __module____name__ __qualname____doc__)hasattrsetattrgetattr__dict__update)newoldr\rrr _wrap+s  z_check_name.._wraprJ) _bootstrapr)rrrrrr _check_names   rcCsHtdt||\}}|dur"t|r"d}t||dt|S)zTry to find a loader for the specified module by delegating to self.find_loader(). This method is deprecated in favor of finder.find_spec(). zZfind_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadNz,Not importing directory {}: missing __init__r)rsrtru find_loaderrra ImportWarning)rfullnameloaderportionsmsgrrr _find_module_shim5srcCs|dd}|tkr d|d|}td|t|fi|t|dkr5d|}td|t|t|dd}|d @rQd |d |}t|fi||S) aTPerform basic validity checking of a pyc header and return the flags field, which determines how the pyc should be further validated against the source. *data* is the contents of the pyc file. (Only the first 16 bytes are required, though.) *name* is the name of the module being imported. It is used for logging. *exc_details* is a dictionary passed to ImportError if it raised for improved debugging. ImportError is raised when the magic number is incorrect or when the flags field is invalid. EOFError is raised when the data is found to be truncated. Nr$zbad magic number in z: {}z(reached EOF while reading pyc header of zinvalid flags z in ) MAGIC_NUMBERr_verbose_messagerrEOFErrorr/)r.r exc_detailsmagicrrrrr _classify_pycIs     rcCs|t|dd|d@krd|}td|t|fi||dur:t|dd|d@krB}|t|t|dksJ|||t||S)z&Produce the data for a hash-based pyc.rr)rrrr)rrr)rrcheckedr.rrrr _code_to_hash_pycs  rcCs>ddl}t|j}||}tdd}|||dS)zyDecode bytes representing source code and return the string. Universal newline support is used in the decoding. rNT)tokenizergBytesIOreadlinedetect_encodingIncrementalNewlineDecoderdecode) source_bytesrsource_bytes_readlineencodingnewline_decoderrrr decode_sources    rrsubmodule_search_locationsc Cs6|durd}t|drz||}Wn&tyYnwnt|}t|s9z tt|}Wn ty8Ynwt j |||d}d|_ |durct D]\}}| t|r`|||}||_nqKdS|turt|drz||}Wn ty|Yn w|rg|_n||_|jgkr|rt|d}|j||S)a=Return a module spec based on a file location. To indicate that the module is a package, set submodule_search_locations to a list of directory paths. An empty list is sufficient, though its not otherwise useful to the import system. The loader must take a spec as its only __init__() arg. Nz get_filenameoriginT is_packager)rrrrrwr]rHrYrRr ModuleSpec _set_fileattr_get_supported_file_loadersr?rr _POPULATErrrOrB) rlocationrrspec loader_classsuffixesrdirnamerrr spec_from_file_locationsT            rc@sXeZdZdZdZdZeodevZe ddZ e ddZ e dd d Z e dd d Zd S)WindowsRegistryFinderz>Meta path finder for modules declared in the Windows registry.z;Software\Python\PythonCore\{sys_version}\Modules\{fullname}zASoftware\Python\PythonCore\{sys_version}\Modules\{fullname}\Debugz_d.pydcCs2zttj|WStyttj|YSwrJ)winregOpenKeyHKEY_CURRENT_USERrRHKEY_LOCAL_MACHINErrrr _open_registry&s  z$WindowsRegistryFinder._open_registrycCs|jr|j}n|j}|j|dtjddd}z ||}t|d}WdW|S1s1wYW|St yBYdSw)Nz%d.%dr1)r sys_versionr ) DEBUG_BUILDREGISTRY_KEY_DEBUG REGISTRY_KEYrar version_inforr QueryValuerR)clsr registry_keyrhkeyfilepathrrr _search_registry-s    z&WindowsRegistryFinder._search_registryNcCsx||}|dur dSzt|Wn tyYdSwtD]\}}|t|r9tj|||||d}|SqdS)Nr)rrQrRrr?rrspec_from_loader)rrrFtargetrrrrrrr find_spec<s"   zWindowsRegistryFinder.find_speccCs*tdt|||}|dur|jSdS)zjFind module named in the registry. This method is deprecated. Use find_spec() instead. zpWindowsRegistryFinder.find_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadNrsrtrurrrrrFrrrr find_moduleLs z!WindowsRegistryFinder.find_moduleNNrJ)rrrrr r  _MS_WINDOWSEXTENSION_SUFFIXESr  staticmethodr classmethodrrrrrrr rs    rc@s0eZdZdZddZddZddZdd Zd S) _LoaderBasicszSBase class of common code needed by both SourceLoader and SourcelessFileLoader.cCs@t||d}|ddd}|dd}|dko|dkS)zConcrete implementation of InspectLoader.is_package by checking if the path returned by get_filename has a filename of '__init__.py'.rrqrr1__init__)rOrrrx)rrr filename_base tail_namerrr rbsz_LoaderBasics.is_packagecCrz*Use default semantics for module creation.Nrrrrrr create_modulejz_LoaderBasics.create_modulecCs8||j}|durtd|jtt||jdS)zExecute the module.Nz4cannot load module {!r} when get_code() returns None)get_coderrrar_call_with_frames_removedexecr)rmodulerrrr exec_modulems z_LoaderBasics.exec_modulecCs t||S)zThis method is deprecated.)r_load_module_shimrrrrr load_moduleus z_LoaderBasics.load_moduleN)rrrrrr$r*r-rrrr r]s  rc@sJeZdZddZddZddZddZd d Zd d d dZddZ dS) SourceLoadercCst)zOptional method that returns the modification time (an int) for the specified path (a str). Raises OSError when the path cannot be handled. )rRrrFrrr path_mtime}szSourceLoader.path_mtimecCsd||iS)aOptional method returning a metadata dict for the specified path (a str). Possible keys: - 'mtime' (mandatory) is the numeric timestamp of last source code modification; - 'size' (optional) is the size in bytes of the source code. Implementing this method allows the loader to read bytecode files. Raises OSError when the path cannot be handled. r)r0r/rrr path_statss zSourceLoader.path_statscCs |||S)zOptional method which writes data (bytes) to a file path (a str). Implementing this method allows for the writing of bytecode files. The source path is needed in order to correctly transfer permissions )set_data)rr cache_pathr.rrr _cache_bytecodes zSourceLoader._cache_bytecodecCr)zOptional method which writes data (bytes) to a file path (a str). Implementing this method allows for the writing of bytecode files. Nr)rrFr.rrr r2r%zSourceLoader.set_datac CsF||}z ||}Wt|Sty"}ztd|d|d}~ww)z4Concrete implementation of InspectLoader.get_source.z'source not available through get_data()rN)rget_datarRrr)rrrFrexcrrr get_sources  zSourceLoader.get_sourcer) _optimizecCstjt||dd|dS)zReturn the code object compiled from source. The 'data' argument can be any object type that compile() supports. r(T) dont_inheritr|)rr'compile)rr.rFr8rrr source_to_codes zSourceLoader.source_to_codec Cs||}d}d}d}d}d}zt|}Wn ty d}Ynwz||} Wn ty1Ynwt| d}z||} Wn tyHYnhw||d} zGt| || } t| dd} | d@dk}|r| d @dk}t j d kr|swt j d kr||}t t |}t | ||| n t| || d || Wn ttfyYnwtd ||t| |||dS|dur||}|||}td|tjs|dur|dur|r|durt |}t|||} nt||t|} z |||| W|StyY|Sw|S)zConcrete implementation of InspectLoader.get_code. Reading of bytecode requires path_stats to be implemented. To write bytecode, set_data must also be implemented. NFTrrrrrr1neveralwayssizez {} matches {})rrrzcode object from {})rrr{r1rRr&r5r memoryviewrcheck_hash_based_pycsr_RAW_MAGIC_NUMBERrrrrrrrr;rdont_write_bytecoderrrr4)rrrrrr hash_based check_sourcerstr.rr bytes_data code_objectrrr r&s                 zSourceLoader.get_codeN) rrrr0r1r4r2r7r;r&rrrr r.{s  r.cs\eZdZdZddZddZddZefdd Zed d Z d d Z eddZ Z S) FileLoaderzgBase file loader class which implements the loader protocol methods that require file system usage.cCs||_||_dS)zKCache the module name and the path to the file found by the finder.Nr)rrrFrrr rs zFileLoader.__init__cC|j|jko |j|jkSrJ __class__rrotherrrr __eq__  zFileLoader.__eq__cCt|jt|jASrJhashrrFrrrr __hash__zFileLoader.__hash__cstt||S)zdLoad a module from a file. This method is deprecated. Use exec_module() instead. )superrHr-r,rKrr r-s zFileLoader.load_modulecC|jSz:Return the path to the source file as found by the finder.rLr,rrr r)zFileLoader.get_filenamecCst|ttfr$tt| }|WdS1swYdSt|d }|WdS1s9wYdS)z'Return the data from path as raw bytes.Nr)rr.ExtensionFileLoaderrg open_coder}readrh)rrFrmrrr r5.s$$zFileLoader.get_datacCsddlm}||S)Nr) FileReader)importlib.readersr_)rr)r_rrr get_resource_reader7s zFileLoader.get_resource_reader) rrrrrrNrTrr-rr5ra __classcell__rrrWr rH s  rHc@s.eZdZdZddZddZdddd Zd S) SourceFileLoaderz>Concrete implementation of SourceLoader using the file system.cCst|}|j|jdS)z!Return the metadata for the path.)rr>)rQst_mtimest_size)rrFrErrr r1AszSourceFileLoader.path_statscCst|}|j|||dS)N_mode)rr2)rrrr.rTrrr r4Fsz SourceFileLoader._cache_bytecoder^rfc Cst|\}}g}|rt|st|\}}|||rt|rt|D]1}t||}zt|Wq#ty:Yq#tyT}zt d||WYd}~dSd}~wwzt |||t d|WdSty~}zt d||WYd}~dSd}~ww)zWrite bytes data to a file.zcould not create {!r}: {!r}Nz created {!r}) rOrZrBreversedrHrmkdirFileExistsErrorrRrrrn) rrFr.rgparentrrDrIr6rrr r2Ks8        zSourceFileLoader.set_dataN)rrrrr1r4r2rrrr rc=s rcc@s eZdZdZddZddZdS)SourcelessFileLoaderz-Loader which handles sourceless file imports.cCsD||}||}||d}t|||tt|dd||dS)Nrr)rr)rr5rrr?)rrrFr.rrrr r&ns   zSourcelessFileLoader.get_codecCr)z'Return None as there is no source code.Nrr,rrr r7~rzSourcelessFileLoader.get_sourceN)rrrrr&r7rrrr rljs rlc@s\eZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ e ddZ dS)r\z]Loader for extension modules. The constructor is designed to work with FileFinder. cCs||_||_dSrJr)rrrFrrr rs zExtensionFileLoader.__init__cCrIrJrJrLrrr rNrOzExtensionFileLoader.__eq__cCrPrJrQrSrrr rTrUzExtensionFileLoader.__hash__cCs$ttj|}td|j|j|S)z&Create an unitialized extension modulez&extension module {!r} loaded from {!r})rr'rcreate_dynamicrrrF)rrr)rrr r$sz!ExtensionFileLoader.create_modulecCs$ttj|td|j|jdS)zInitialize an extension modulez(extension module {!r} executed from {!r}N)rr'r exec_dynamicrrrFrr)rrr r*szExtensionFileLoader.exec_modulecs$t|jdtfddtDS)z1Return True if the extension module is a package.rc3s|] }d|kVqdS)rNrrsuffix file_namerr r sz1ExtensionFileLoader.is_package..)rOrFanyrr,rrrr rs zExtensionFileLoader.is_packagecCr)z?Return None as an extension module cannot create a code object.Nrr,rrr r&rzExtensionFileLoader.get_codecCr)z5Return None as extension modules have no source code.Nrr,rrr r7rzExtensionFileLoader.get_sourcecCrXrYrLr,rrr rrZz ExtensionFileLoader.get_filenameN)rrrrrrNrTr$r*rr&r7rrrrrr r\sr\c@sleZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZdS)_NamespacePatha&Represents a namespace package's path. It uses the module name to find its parent module, and from there it looks up the parent's __path__. When this changes, the module's own path is recomputed, using path_finder. For top-level modules, the parent module's path is sys.path.rcCs,||_||_t||_|j|_||_dSrJ)_name_pathr_get_parent_path_last_parent_path_epoch _last_epoch _path_finderrrrF path_finderrrr rs  z_NamespacePath.__init__cCs&|jd\}}}|dkrdS|dfS)z>Returns a tuple of (parent-module-name, parent-path-attr-name)rqr )rrF__path__)rvrx)rrkdotmerrr _find_parent_path_namessz&_NamespacePath._find_parent_path_namescCs|\}}ttj||SrJ)rrrmodules)rparent_module_namepath_attr_namerrr rxs z_NamespacePath._get_parent_pathcCsdt|}||jks|j|jkr/||j|}|dur(|jdur(|jr(|j|_ ||_|j|_|j SrJ) rrxryrzr{r|rvrrrw)r parent_pathrrrr _recalculates z_NamespacePath._recalculatecC t|SrJ)iterrrSrrr __iter__ z_NamespacePath.__iter__cCs ||SrJr)rindexrrr __getitem__rz_NamespacePath.__getitem__cCs||j|<dSrJ)rw)rrrFrrr __setitem__sz_NamespacePath.__setitem__cCrrJ)rrrSrrr __len__rz_NamespacePath.__len__cC d|jS)Nz_NamespacePath({!r}))rarwrSrrr __repr__rz_NamespacePath.__repr__cCs ||vSrJrritemrrr __contains__rz_NamespacePath.__contains__cCs|j|dSrJ)rwrBrrrr rBz_NamespacePath.appendN)rrrrrzrrrxrrrrrrrrBrrrr rus  ruc@sXeZdZddZeddZddZddZd d Zd d Z d dZ ddZ ddZ dS)_NamespaceLoadercCst||||_dSrJ)rurwr}rrr rsz_NamespaceLoader.__init__cCstdtd|jS)zsReturn repr for the module. The method is deprecated. The import machinery does the job itself. zR_NamespaceLoader.module_repr() is deprecated and slated for removal in Python 3.12z)rsrtrurar)r)rrr module_reprs z_NamespaceLoader.module_reprcCr)NTrr,rrr r z_NamespaceLoader.is_packagecCr)Nr rr,rrr r7rz_NamespaceLoader.get_sourcecCstdddddS)Nr zr(T)r9)r:r,rrr r&rz_NamespaceLoader.get_codecCrr"rr#rrr r$r%z_NamespaceLoader.create_modulecCsdSrJrrorrr r*rz_NamespaceLoader.exec_modulecCstd|jt||S)zbLoad a namespace module. This method is deprecated. Use exec_module() instead. z&namespace module loaded with path {!r})rrrwr+r,rrr r-s z_NamespaceLoader.load_modulecCsddlm}||jS)Nr)NamespaceReader)r`rrw)rr)rrrr ra's  z$_NamespaceLoader.get_resource_readerN) rrrrrrrr7r&r$r*r-rarrrr rs   rc@sveZdZdZeddZeddZeddZedd Z edd d Z edd dZ edddZ eddZ d S) PathFinderz>Meta path finder for sys.path and package __path__ attributes.cCsNttjD]\}}|durtj|=qt|dr|qtjd7_dS)z}Call the invalidate_caches() method on all path entry finders stored in sys.path_importer_caches (where implemented).Ninvalidate_cachesr)listrpath_importer_cacheitemsrrrurz)rfinderrrr r2s  zPathFinder.invalidate_cachesc CsLtjdurtjstdttjD]}z||WSty#YqwdS)z.Search sys.path_hooks for a finder for 'path'.Nzsys.path_hooks is empty)r path_hooksrsrtrr)rFhookrrr _path_hooks?s   zPathFinder._path_hookscCsd|dkrzt}Wn tyYdSwztj|}W|Sty1||}|tj|<Y|Sw)zGet the finder for the path entry from sys.path_importer_cache. If the path entry is not in the cache, find the appropriate finder and cache it. If no finder is available, store None. r N)rrYFileNotFoundErrorrrKeyErrorr)rrFrrrr _path_importer_cacheLs     zPathFinder._path_importer_cachecCst|drt|d}t|t||\}}nt|d}t|t||}g}|dur:t||St |d}||_ |S)Nrz5.find_spec() not found; falling back to find_loader()z5.find_spec() not found; falling back to find_module()) rr _object_namersrtrrrrrr)rrrrrrrrrr _legacy_get_specbs      zPathFinder._legacy_get_specNc Csg}|D]C}t|ttfsq||}|durGt|dr#|||}n|||}|dur.q|jdur7|S|j}|durBt d| |qt |d}||_|S)z?Find the loader or namespace_path for this module/package name.Nrzspec missing loader) rr}bytesrrrrrrrrrr) rrrFrnamespace_pathentryrrrrrr _get_specws*      zPathFinder._get_speccCs^|durtj}||||}|durdS|jdur-|j}|r+d|_t|||j|_|SdS|S)zTry to find a spec for 'fullname' on sys.path or 'path'. The search is based on sys.path_hooks and sys.path_importer_cache. N)rrFrrrrru)rrrFrrrrrr rs zPathFinder.find_speccCs*tdt|||}|durdS|jS)zfind the module on sys.path or 'path' based on sys.path_hooks and sys.path_importer_cache. This method is deprecated. Use find_spec() instead. zePathFinder.find_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadNrrrrr rs zPathFinder.find_modulecOsddlm}|j|i|S)a  Find distributions. Return an iterable of all Distribution instances capable of loading the metadata for packages matching ``context.name`` (or all names if ``None`` indicated) along the paths in the list of directories ``context.path``. r)MetadataPathFinder)importlib.metadatarfind_distributions)rrrrrr rs zPathFinder.find_distributionsrJr)rrrrrrrrrrrrrrrrrr r.s$       rc@sZeZdZdZddZddZeZddZdd Z dd d Z d dZ e ddZ ddZd S) FileFinderzFile-based finder. Interactions with the file system are cached for performance, being refreshed when the directory the finder is handling has been modified. cspg}|D]\}|fdd|Dq||_|pd|_t|js+tt|j|_d|_t|_ t|_ dS)zInitialize with the path to search on and a variable number of 2-tuples containing the loader and the file suffixes the loader recognizes.c3s|]}|fVqdSrJrrprrr r sz&FileFinder.__init__..rqrN) r_loadersrFr]rHrrY _path_mtimeset _path_cache_relaxed_path_cache)rrFloader_detailsloadersrrrr rs    zFileFinder.__init__cCs d|_dS)zInvalidate the directory mtime.rN)rrSrrr rrXzFileFinder.invalidate_cachescCs6tdt||}|durdgfS|j|jpgfS)zTry to find a loader for the specified module, or the namespace package portions. Returns (loader, list-of-portions). This method is deprecated. Use find_spec() instead. zeFileFinder.find_loader() is deprecated and slated for removal in Python 3.12; use find_spec() insteadN)rsrtrurrr)rrrrrr rs zFileFinder.find_loadercCs|||}t||||dS)Nr)r)rrrrFsmslrrrrr rs zFileFinder._get_specNc Cszd}|dd}z t|jptj}Wn ty d}Ynw||jkr-|||_t r8|j }| }n|j }|}||vrlt |j|}|jD]\} } d| } t || } t| rg|| || |g|SqJt|}|jD]7\} } z t |j|| } Wn tyYdSwtjd| dd|| |vrt| r|| || d|Sqo|rtd |t|d} |g| _| SdS) zoTry to find a spec for the specified module. Returns the matching spec, or None if not found. Frqr1rrNz trying {}) verbosityzpossible namespace for {})rxrQrFrrYrdrRr _fill_cacherrrrrHrrWrrZrrrrr)rrr is_namespace tail_modulercache cache_module base_pathrqr init_filename full_pathrrrr rsV          zFileFinder.find_specc Cs|j}z t|p t}Wntttfyg}Ynwtj ds)t ||_ n%t }|D]}| d\}}}|rCd ||}n|}||q.||_ tj tr^dd|D|_dSdS)zDFill the cache of potential modules and packages for this directory.rrqr_cSsh|]}|qSr)r)rfnrrr rPsz)FileFinder._fill_cache..N)rFrlistdirrYrPermissionErrorNotADirectoryErrorrrrrrrraraddr r) rrFcontentslower_suffix_contentsrrrrqnew_namerrr r3s&    zFileFinder._fill_cachecsfdd}|S)aA class method which returns a closure to use on sys.path_hook which will return an instance using the specified loaders and the path called on the closure. If the path called on the closure is not a directory, ImportError is raised. cs$t|s td|d|gRS)z-Path hook for importlib.machinery.FileFinder.zonly directories are supportedrL)rZrrLrrrr path_hook_for_FileFinder\s z6FileFinder.path_hook..path_hook_for_FileFinderr)rrrrrr path_hookRs zFileFinder.path_hookcCr)NzFileFinder({!r}))rarFrSrrr rdrzFileFinder.__repr__rJ)rrrrrrrrrrrrrrrrrrr rs 3  rcCs|d}|d}|s!|r|j}n||krt||}nt||}|s*t|||d}z||d<||d<||d<||d<WdStyGYdSw)N __loader____spec__r__file__ __cached__)getrrlrcr Exception)nsrpathname cpathnamerrrrr _fix_up_modulejs$     rcCs&ttf}ttf}ttf}|||gS)z_Returns a list of file-based module loaders. Each item is a tuple (loader, suffixes). )r\rextension_suffixesrcrrlr) extensionssourcebytecoderrr rs  rcCs|adSrJ)r)_bootstrap_modulerrr _set_bootstrap_modulesrcCs2t|t}tjtj|gtjt dS)z)Install the path-based import components.N) rrrrrrr meta_pathrBr)rsupported_loadersrrr _installsr)r^rJ)NNN)rr)T)Urrrrgrrsrrrntrrposixr7allr@rr>rC_pathseps_with_colonr!%_CASE_INSENSITIVE_PLATFORMS_BYTES_KEYr r"rr)r/r2rHrOrQrVrWrZr]rntype__code__rr'rr&r,rArrrrBrrrDEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESrrrrrrrrrrrrrrobjectrrrrr.rHrcrlr\rurrrrrrrrrrr s            G(  !    IC2-5E1