o [dR@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. Nwin32\/ccs|] }t|dkVqdS)N)len).0sepr 4/usr/lib/python3.10/importlib/_bootstrap_external.py .sr cCsh|]}d|qS):r )rsr r r 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_osenvironr keyr r _relax_caseCz%_make_relax_case.._relax_casecSdS)z5True if filenames must be checked case-insensitively.Fr r r r r rG)rplatform startswith_CASE_INSENSITIVE_PLATFORMS#_CASE_INSENSITIVE_PLATFORMS_STR_KEY)rr rr _make_relax_case<s   r#cCst|d@ddS)z*Convert a 32-bit integer to little-endian.little)intto_bytes)xr r r _pack_uint32Orr*cCt|dksJt|dS)z/Convert 4 bytes in little-endian to an integer.r%r&rr' from_bytesdatar r r _unpack_uint32T r0cCr+)z/Convert 2 bytes in little-endian to an integer.r&r,r.r r r _unpack_uint16Yr1r3cGs|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|tqSr rstrippath_separatorsrpr r r ws_path_join..) rmapr_path_splitrootr path_sep_tupleendswithr7r8path_sepcasefoldappendjoin) path_partsrootpathnew_roottailr r r _path_join`s*     rJcGstdd|DS)r4cSr5r r6)rpartr r r r;sr<)rArD)rEr r r rJ~s csBtfddtD}|dkrdfSd||ddfS)z Replacement for os.path.split().c3s|]}|VqdSN)rfindr9rGr r r sz_path_split..rr Nr)maxr8)rGir rNr _path_splitsrQcCs t|S)z~Stat the path. Made a separate function to make it easier to override in experiments (e.g. cache stat results). )rstatrNr r r _path_stats rScCs0zt|}Wn tyYdSw|jd@|kS)z1Test whether the path is the specified mode type.Fi)rSOSErrorst_mode)rGmode stat_infor r r _path_is_mode_types   rXcCs t|dS)zReplacement for os.path.isfile.i)rXrNr r r _path_isfile rYcCs|st}t|dS)zReplacement for os.path.isdir.i@)rgetcwdrXrNr r r _path_isdirs r\cCs>|sdSt|ddd}t|dko|dp|dS)Replacement for os.path.isabs.Frrrrz\\)rr>replacerr r@)rGrFr r r _path_isabss r_cCs |tS)r])r r8rNr r r r_rZc 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^rTunlink)rGr/rVpath_tmpfdfiler r r _write_atomics$    rpio r2r&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 r2) _warningswarnDeprecationWarning TypeErrorrfspathrQ rpartitionrimplementation cache_tagNotImplementedErrorrDroptimizestrisalnum ValueErrorrc_OPTBYTECODE_SUFFIXESpycache_prefixr_rJr[r8lstrip_PYCACHE) rGdebug_overriderrmessageheadrIbaserresttagalmost_filenamefilenamer r r 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. NrtFTz not bottom-level directory in rs>r2zexpected only 2 or 3 dots in rr2z5optimization portion of filename does not start with zoptimization level z is not an alphanumeric valuer)rr{r|r}rryrQrr7r8r rArrrcountrsplitrr partitionrJSOURCE_SUFFIXES) rGrpycache_filenamefound_in_pycache_prefix stripped_pathpycache dot_countrr opt_level base_filenamer r r 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. rNrspy)rrzlowerrr}rrY) bytecode_pathr_ extension source_pathr r r _get_sourcefiles  rcCsD|ttrzt|WStyYdSw|ttr |SdSrL)r@tuplerrr}r)rr r r _get_cacheds  rcCs2zt|j}Wn tyd}Ynw|dO}|S)z3Calculate the mode permissions for a bytecode file.r`)rSrUrT)rGrVr r r _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)selfrargskwargsmethodr r _check_name_wrappers z(_check_name.._check_name_wrappercSs8dD]}t||rt||t||q|j|jdS)N) __module____name__ __qualname____doc__)hasattrsetattrgetattr__dict__update)newoldr^r r r _wrap+s  z_check_name.._wraprL) _bootstrapr)rrrr rr _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)rurvrw find_loaderrrc ImportWarning)rfullnameloaderportionsmsgr r r _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_messagerrEOFErrorr0)r/r exc_detailsmagicrrr r r _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/rr r r _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)tokenizeriBytesIOreadlinedetect_encodingIncrementalNewlineDecoderdecode) source_bytesrsource_bytes_readlineencodingnewline_decoderr r r 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)rrrrryr_rJr[rTr ModuleSpec _set_fileattr_get_supported_file_loadersr@rr _POPULATErrrQrC) rlocationrrspec loader_classsuffixesrdirnamer r r 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|YSwrL)winregOpenKeyHKEY_CURRENT_USERrTHKEY_LOCAL_MACHINErr r r _open_registry&s  z$WindowsRegistryFinder._open_registrycCs|jr|j}n|j}|j|dtjddd}z ||}t|d}WdW|S1s1wYW|St yBYdSw)Nz%d.%dr2)r sys_versionr ) DEBUG_BUILDREGISTRY_KEY_DEBUG REGISTRY_KEYrcr version_infor r QueryValuerT)clsr registry_keyrhkeyfilepathr r r _search_registry-s    z&WindowsRegistryFinder._search_registryNcCsx||}|dur dSzt|Wn tyYdSwtD]\}}|t|r9tj|||||d}|SqdS)Nr)rrSrTrr@rrspec_from_loader)rrrGtargetrrrrr r r 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() insteadNrurvrwrrrrrGrr r r find_moduleLs z!WindowsRegistryFinder.find_moduleNNrL)rrrrr r  _MS_WINDOWSEXTENSION_SUFFIXESr  staticmethodr  classmethodrrrr r r r 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'.rrsrr2__init__)rQrrrz)rrr filename_base tail_namer r r rbsz_LoaderBasics.is_packagecCrz*Use default semantics for module creation.Nr rrr r r create_modulejz_LoaderBasics.create_modulecCs8||j}|durtd|jtt||jdS)zExecute the module.Nz4cannot load module {!r} when get_code() returns None)get_coderrrcr_call_with_frames_removedexecr)rmodulerr r r exec_modulems z_LoaderBasics.exec_modulecCs t||S)zThis method is deprecated.)r_load_module_shimrrr r r load_moduleus z_LoaderBasics.load_moduleN)rrrrrr&r,r/r r r r r ]s  r c@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. )rTrrGr r r 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)r2r1r r r 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/r r r _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 )rrGr/r r r r4r'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_datarTrr)rrrGrexcr r r 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/rGr:r r r 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. NFTrrrrrr2neveralwayssizez {} matches {})rrrzcode object from {})rrr}r3rTr'r7r memoryviewrcheck_hash_based_pycsr_RAW_MAGIC_NUMBERrrrrrrrr=rdont_write_bytecoderrrr6)rrrrrr hash_based check_sourcerstr/rr bytes_data code_objectr r r r(s                 zSourceLoader.get_codeN) rrrr2r3r6r4r9r=r(r r r r r0{s  r0cs\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)rrrGr r r r!s zFileLoader.__init__cC|j|jko |j|jkSrL __class__rrotherr r r __eq__  zFileLoader.__eq__cCt|jt|jASrLhashrrGrr r r __hash__zFileLoader.__hash__cstt||S)zdLoad a module from a file. This method is deprecated. Use exec_module() instead. )superrJr/r.rMr r r/s zFileLoader.load_modulecC|jSz:Return the path to the source file as found by the finder.rNr.r r r r)zFileLoader.get_filenamecCst|ttfr$tt| }|WdS1swYdSt|d }|WdS1s9wYdS)z'Return the data from path as raw bytes.Nr)rr0ExtensionFileLoaderri open_coderreadrj)rrGror r r r7.s$$zFileLoader.get_datacCsddlm}||S)Nr) FileReader)importlib.readersra)rr+rar r r get_resource_reader7s zFileLoader.get_resource_reader) rrrrr!rPrVrr/rr7rc __classcell__r r rYr rJ s  rJc@s.eZdZdZddZddZdddd Zd S) SourceFileLoaderz>Concrete implementation of SourceLoader using the file system.cCst|}|j|jdS)z!Return the metadata for the path.)rr@)rSst_mtimest_size)rrGrGr r r r3AszSourceFileLoader.path_statscCst|}|j|||dS)N_mode)rr4)rrrr/rVr r r r6Fsz SourceFileLoader._cache_bytecoder`rhc 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}) rQr\rCreversedrJrmkdirFileExistsErrorrTrrrp) rrGr/riparentrrErKr8r r r r4Ks8        zSourceFileLoader.set_dataN)rrrrr3r6r4r r r r re=s rec@s eZdZdZddZddZdS)SourcelessFileLoaderz-Loader which handles sourceless file imports.cCsD||}||}||d}t|||tt|dd||dS)Nrr)rr)rr7rrrA)rrrGr/rr r r r(ns   zSourcelessFileLoader.get_codecCr)z'Return None as there is no source code.Nr r.r r r r9~rzSourcelessFileLoader.get_sourceN)rrrrr(r9r r r r rnjs rnc@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||_||_dSrLr)rrrGr r r r!s zExtensionFileLoader.__init__cCrKrLrLrNr r r rPrQzExtensionFileLoader.__eq__cCrRrLrSrUr r r rVrWzExtensionFileLoader.__hash__cCs$ttj|}td|j|j|S)z&Create an unitialized extension modulez&extension module {!r} loaded from {!r})rr)rcreate_dynamicrrrG)rrr+r r r r&sz!ExtensionFileLoader.create_modulecCs$ttj|td|j|jdS)zInitialize an extension modulez(extension module {!r} executed from {!r}N)rr)r exec_dynamicrrrGrr+r r r r,szExtensionFileLoader.exec_modulecs$t|jdtfddtDS)z1Return True if the extension module is a package.rc3s|] }d|kVqdS)r!Nr rsuffix file_namer r r sz1ExtensionFileLoader.is_package..)rQrGanyrr.r rtr rs zExtensionFileLoader.is_packagecCr)z?Return None as an extension module cannot create a code object.Nr r.r r r r(rzExtensionFileLoader.get_codecCr)z5Return None as extension modules have no source code.Nr r.r r r r9rzExtensionFileLoader.get_sourcecCrZr[rNr.r r r rr\z ExtensionFileLoader.get_filenameN)rrrrr!rPrVr&r,rr(r9rrr r r r 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|_||_dSrL)_name_pathr_get_parent_path_last_parent_path_epoch _last_epoch _path_finderrrrG path_finderr r r r!s  z_NamespacePath.__init__cCs&|jd\}}}|dkrdS|dfS)z>Returns a tuple of (parent-module-name, parent-path-attr-name)rsr )rrG__path__)rxrz)rrmdotmer r r _find_parent_path_namessz&_NamespacePath._find_parent_path_namescCs|\}}ttj||SrL)rrrmodules)rparent_module_namepath_attr_namer r r rzs z_NamespacePath._get_parent_pathcCsdt|}||jks|j|jkr/||j|}|dur(|jdur(|jr(|j|_ ||_|j|_|j SrL) rrzr{r|r}r~rxrrry)r parent_pathrr r r _recalculates z_NamespacePath._recalculatecC t|SrL)iterrrUr r r __iter__ z_NamespacePath.__iter__cCs ||SrLr)rindexr r r __getitem__rz_NamespacePath.__getitem__cCs||j|<dSrL)ry)rrrGr r r __setitem__sz_NamespacePath.__setitem__cCrrL)rrrUr r r __len__rz_NamespacePath.__len__cC d|jS)Nz_NamespacePath({!r}))rcryrUr r r __repr__rz_NamespacePath.__repr__cCs ||vSrLrritemr r r __contains__rz_NamespacePath.__contains__cCs|j|dSrL)ryrCrr r r rCz_NamespacePath.appendN)rrrrr|r!rrzrrrrrrrrCr r r r rws  rwc@sXeZdZddZeddZddZddZd d Zd d Z d dZ ddZ ddZ dS)_NamespaceLoadercCst||||_dSrL)rwryrr r r r!sz_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)rurvrwrcr)r+r r r module_reprs z_NamespaceLoader.module_reprcCr)NTr r.r r r r z_NamespaceLoader.is_packagecCr)Nr r r.r r r r9rz_NamespaceLoader.get_sourcecCstdddddS)Nr zr*T)r;)r<r.r r r r(rz_NamespaceLoader.get_codecCrr$r r%r r r r&r'z_NamespaceLoader.create_modulecCsdSrLr rqr r r 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})rrryr-r.r r r r/s z_NamespaceLoader.load_modulecCsddlm}||jS)Nr)NamespaceReader)rbrry)rr+rr r r rc's  z$_NamespaceLoader.get_resource_readerN) rrrr!rrrr9r(r&r,r/rcr r r r 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_cacheitemsrrrwr|)rfinderr r r 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_hooksrurvrr)rGhookr r r _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)rr[FileNotFoundErrorrrKeyErrorr)rrGrr r r _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_namerurvrrrrrr)rrrrrrrr r r _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) rrbytesrrrrrrrrrr) rrrGrnamespace_pathentryrrrr r r _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)rrGrrrrrw)rrrGrrrr r r 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() insteadNrrr r r 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)rrrr r r rs zPathFinder.find_distributionsrLr)rrrrrrrrrrrrrrr r r r 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|]}|fVqdSrLr rrrr r r sz&FileFinder.__init__..rsrN) r_loadersrGr_rJrr[ _path_mtimeset _path_cache_relaxed_path_cache)rrGloader_detailsloadersrr rr r!s    zFileFinder.__init__cCs d|_dS)zInvalidate the directory mtime.rN)rrUr r r rrZzFileFinder.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)rurvrwrrr)rrrr r r rs zFileFinder.find_loadercCs|||}t||||dS)Nr)r)rrrrGsmslrrr r r 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. Frsr2rr!Nz trying {}) verbosityzpossible namespace for {})rzrSrGrr[rfrTr _fill_cacherrrrrJrrYrr\rrrrr)rrr is_namespace tail_modulercache cache_module base_pathrsr init_filename full_pathrr r r 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.rrsracSsh|]}|qSr )r)rfnr r r rPsz)FileFinder._fill_cache..N)rGrlistdirr[rPermissionErrorNotADirectoryErrorrrr rrrrcraddr!r) rrGcontentslower_suffix_contentsrrrrsnew_namer r r 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 supportedrN)r\rrNrrr r path_hook_for_FileFinder\s z6FileFinder.path_hook..path_hook_for_FileFinderr )rrrr rr path_hookRs zFileFinder.path_hookcCr)NzFileFinder({!r}))rcrGrUr r r rdrzFileFinder.__repr__rL)rrrrr!rrrrrrrrrrr r r r 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__)getrrnrer Exception)nsrpathname cpathnamerrr r r _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_suffixesrerrnr) extensionssourcebytecoder r r rs  rcCs|adSrL)r)_bootstrap_moduler r r _set_bootstrap_modulesrcCs2t|t}tjtj|gtjt dS)z)Install the path-based import components.N) rrrrrrr meta_pathrCr)rsupported_loadersr r r _installsr)r`rL)NNN)rr)T)Urrrrirrurrrntrrposixr8allrArr?rD_pathseps_with_colonr"%_CASE_INSENSITIVE_PLATFORMS_BYTES_KEYr!r#rr*r0r3rJrQrSrXrYr\r_rptype__code__rr(rr'r-rCrrrrCrrrDEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESrrrrrrrrrrrrrrobjectrrrr r0rJrernr^rwrrrrrrrr r r r s            G(  !    IC2-5E1