o ?OgR@sdZdaddlZddlZddlZddlZddlZejdkZer(ddl Z ddl Z nddl Z er3ddgZ ndgZ e dZee Zde Z dde DZd Zd ZeeZd d ZeZd dZddZddZerlddZnddZddZddZddZddZddZ erd d!Z!nd"d!Z!dnd$d%Z"e#e"j$Z%d&&d'd(d)Z'e()e'd(Z*d*Z+d+Z,d,gZ-ere-.d-e/Z0d.gZ1e1Z2Z3dodd/d0d1Z4d2d3Z5d4d5Z6d6d7Z7d8d9Z8d:d;Z9dd?Z;d@dAZdqdFdGZ?drdIdJZ@dKdLZAeBZCdodeCdMdNdOZDGdPdQdQZEGdRdSdSZFGdTdUdUeFZGGdVdWdWZHGdXdYdYeHeGZIGdZd[d[eHeFZJGd\d]d]eHeFZKGd^d_d_ZLGd`dadaZMGdbdcdcZNGdddedeZOdodfdgZPdhdiZQdjdkZRdldmZSdS)sa^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\/cCsh|]}d|qS):).0srrD/opt/alt/python310/lib64/python3.10/importlib/_bootstrap_external.py 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   rcCst|d@ddS)z*Convert a 32-bit integer to little-endian.little)intto_bytes)xrrr _pack_uint32Orr%cC t|dS)z/Convert 4 bytes in little-endian to an integer.r!r" from_bytesdatarrr _unpack_uint32T r+cCr&)z/Convert 2 bytes in little-endian to an integer.r!r'r)rrr _unpack_uint16Yr,r-cGs|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().rrrcSg|] }|r|tqSrrstrippath_separatorsrprrr ws_path_join..) lenmapr_path_splitrootrpath_sep_tupleendswithr2r3path_sepcasefoldappendjoin) path_partsrootpathZnew_roottailrrr _path_join`s*     rEcGstdd|DS)r.cSr0rr1)rpartrrr r6sr7)r=r@)rArrr rE~s csBtfddtD}|dkrdfSd||ddfS)z Replacement for os.path.split().c3s|]}|VqdSN)rfindr4rCrr sz_path_split..rrNr/)maxr3)rCirrIr _path_splitsrMcCs t|S)z~Stat the path. Made a separate function to make it easier to override in experiments (e.g. cache stat results). )rstatrIrrr _path_stats rOcCs0zt|}Wn tyYdSw|jd@|kS)z1Test whether the path is the specified mode type.Fi)rOOSErrorst_mode)rCmode stat_inforrr _path_is_mode_types   rTcCs t|dS)zReplacement for os.path.isfile.i)rTrIrrr _path_isfile rUcCs|st}t|dS)zReplacement for os.path.isdir.i@)rgetcwdrTrIrrr _path_isdirs rXcCs>|sdSt|ddd}t|dko|dp|dS)Replacement for os.path.isabs.Frrrr/z\\)rr:replacer8rr<)rCrBrrr _path_isabss r[cCs |tS)rY)rr3rIrrr r[rVc 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_ioFileIOwriterZrPunlink)rCr*rRpath_tmpfdfilerrr _write_atomics$    rlio r!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 Nonerr/.$sys.implementation.cache_tag is Nonerz{!r} is not alphanumericz{}.{}{}rrm) _warningswarnDeprecationWarning TypeErrorrfspathrM rpartitionrimplementation cache_tagNotImplementedErrorr@roptimizestrisalnum ValueErrorr__OPTBYTECODE_SUFFIXESpycache_prefixr[rErWr3lstrip_PYCACHE) rCdebug_overrideromessageheadrDbasesepresttagalmost_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. NrqFTz not bottom-level directory in rp>rmzexpected only 2 or 3 dots in rrmz5optimization portion of filename does not start with zoptimization level z is not an alphanumeric valuer)rrxryrzrrvrMrr2r3rr=r8rr~countrsplitrr} partitionrESOURCE_SUFFIXES) rCrpycache_filenamefound_in_pycache_prefix stripped_pathpycache dot_countro 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. rNrppy)r8rwlowerrrzr~rU) bytecode_pathr_ extension source_pathrrr _get_sourcefiles  rcCsD|ttrzt|WStyYdSw|ttr |SdSrG)r<tuplerrrzr)rrrr _get_cacheds  rcCs2zt|j}Wn tyd}Ynw|dO}|S)z3Calculate the mode permissions for a bytecode file.r\)rOrQrP)rCrRrrr _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)newoldrZrrr _wrap+s  z_check_name.._wraprG) _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)rrrsrt find_loaderr8r_ 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_messagerr8EOFErrorr+)r*r exc_detailsmagicrrrrr _classify_pycIs     rcCs|t|dd|d@krd|}td|t|fi||dur:t|dd|d@krB}|t||||t||S)z&Produce the data for a hash-based pyc.r/r)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)tokenizereBytesIOreadlinedetect_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)rrrrrvr[rErWrPr ModuleSpec _set_fileattr_get_supported_file_loadersr<rr _POPULATErrrMr?) 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|YSwrG)winregOpenKeyHKEY_CURRENT_USERrPHKEY_LOCAL_MACHINErrrr _open_registry&s  z$WindowsRegistryFinder._open_registrycCs|jr|j}n|j}|j|dtjddd}z ||}t|d}WdW|S1s1wYW|St yBYdSw)Nz%d.%drm)r sys_versionr) DEBUG_BUILDREGISTRY_KEY_DEBUG REGISTRY_KEYr_r version_inforr QueryValuerP)clsr registry_keyrhkeyfilepathrrr _search_registry-s    z&WindowsRegistryFinder._search_registryNcCsx||}|dur dSzt|Wn tyYdSwtD]\}}|t|r9tj|||||d}|SqdS)Nr)rrOrPrr<rrspec_from_loader)rrrCtargetrrrrrrr 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() insteadNrrrsrtrrrrrCrrrr find_moduleLs z!WindowsRegistryFinder.find_moduleNNrG)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'.r/rprrm__init__)rMrrrw)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_coderrr_r_call_with_frames_removedexecr)rmodulerrrr exec_modulems z_LoaderBasics.exec_modulecCs t||S)zThis method is deprecated.)r_load_module_shimrrrrr load_moduleur,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. )rPrrCrrr 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)r1r0rrr 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)rrCr*rrr r3r&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_datarPrr)rrrCrexcrrr 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*rCr9rrr 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. NFTrrrr/rrmneveralwayssizez {} matches {})rrrzcode object from {})rrrzr2rPr"r6r memoryviewrcheck_hash_based_pycsr_RAW_MAGIC_NUMBERrrrrrrrr<rdont_write_bytecoderrr8r5)rrrrrr hash_based check_sourcerstr*rr bytes_data code_objectrrr r's                 zSourceLoader.get_codeN) rrrr1r2r5r3r8r<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)rrrCrrr r s zFileLoader.__init__cC|j|jko |j|jkSrG __class__rrotherrrr __eq__  zFileLoader.__eq__cCt|jt|jASrGhashrrCrrrr __hash__zFileLoader.__hash__cstt||S)zdLoad a module from a file. This method is deprecated. Use exec_module() instead. )superrIr.r-rLrr r.s zFileLoader.load_modulecC|jSz:Return the path to the source file as found by the finder.rIr-rrr r)zFileLoader.get_filenamecCst|ttfr$tt| }|WdS1swYdSt|d }|WdS1s9wYdS)z'Return the data from path as raw bytes.Nr)rr/ExtensionFileLoaderre open_coder|readrf)rrCrkrrr r6.s$$zFileLoader.get_datacCsddlm}||S)Nr) FileReader)importlib.readersr`)rr*r`rrr get_resource_reader7s zFileLoader.get_resource_reader) rrrrr rOrUrr.rr6rb __classcell__rrrXr rI s  rIc@s.eZdZdZddZddZdddd Zd S) SourceFileLoaderz>Concrete implementation of SourceLoader using the file system.cCst|}|j|jdS)z!Return the metadata for the path.)rr?)rOst_mtimest_size)rrCrFrrr r2AszSourceFileLoader.path_statscCst|}|j|||dS)N_mode)rr3)rrrr*rRrrr r5Fsz SourceFileLoader._cache_bytecoder\rgc 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}) rMrXr?reversedrErmkdirFileExistsErrorrPrrrl) rrCr*rhparentrrArFr7rrr r3Ks8        zSourceFileLoader.set_dataN)rrrrr2r5r3rrrr rd=s rdc@s eZdZdZddZddZdS)SourcelessFileLoaderz-Loader which handles sourceless file imports.cCsD||}||}||d}t|||tt|dd||dS)Nrr)rr)rr6rrr@)rrrCr*rrrr r'ns   zSourcelessFileLoader.get_codecCr)z'Return None as there is no source code.Nrr-rrr r8~rzSourcelessFileLoader.get_sourceN)rrrrr'r8rrrr rmjs rmc@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||_||_dSrGr)rrrCrrr r s zExtensionFileLoader.__init__cCrJrGrKrMrrr rOrPzExtensionFileLoader.__eq__cCrQrGrRrTrrr rUrVzExtensionFileLoader.__hash__cCs$ttj|}td|j|j|S)z&Create an unitialized extension modulez&extension module {!r} loaded from {!r})rr(rcreate_dynamicrrrC)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_dynamicrrrCrr*rrr r+szExtensionFileLoader.exec_modulecs$t|jdtfddtDS)z1Return True if the extension module is a package.r/c3s|] }d|kVqdS)r Nrrsuffix file_namerr rJsz1ExtensionFileLoader.is_package..)rMrCanyrr-rrsr 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 r8rzExtensionFileLoader.get_sourcecCrYrZrIr-rrr rr[z ExtensionFileLoader.get_filenameN)rrrrr rOrUr%r+rr'r8rrrrrr 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|_||_dSrG)_name_pathr_get_parent_path_last_parent_path_epoch _last_epoch _path_finderrrrC path_finderrrr r s  z_NamespacePath.__init__cCs&|jd\}}}|dkrdS|dfS)z>Returns a tuple of (parent-module-name, parent-path-attr-name)rpr)rrC__path__)rwrw)rrldotmerrr _find_parent_path_namessz&_NamespacePath._find_parent_path_namescCs|\}}ttj||SrG)rrrmodules)rparent_module_namepath_attr_namerrr rys z_NamespacePath._get_parent_pathcCsdt|}||jks|j|jkr/||j|}|dur(|jdur(|jr(|j|_ ||_|j|_|j SrG) rryrzr{r|r}rwrrrx)r parent_pathrrrr _recalculates z_NamespacePath._recalculatecC t|SrG)iterrrTrrr __iter__ z_NamespacePath.__iter__cCs ||SrGr)rindexrrr __getitem__rz_NamespacePath.__getitem__cCs||j|<dSrG)rx)rrrCrrr __setitem__sz_NamespacePath.__setitem__cCrrG)r8rrTrrr __len__rz_NamespacePath.__len__cC d|jS)Nz_NamespacePath({!r}))r_rxrTrrr __repr__rz_NamespacePath.__repr__cCs ||vSrGrritemrrr __contains__rz_NamespacePath.__contains__cCs|j|dSrG)rxr?rrrr r?z_NamespacePath.appendN)rrrrr{r rryrrrrrrrr?rrrr rvs  rvc@sXeZdZddZeddZddZddZd d Zd d Z d dZ ddZ ddZ dS)_NamespaceLoadercCst||||_dSrG)rvrxr~rrr 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)rrrsrtr_r)r*rrr module_reprs z_NamespaceLoader.module_reprcCr)NTrr-rrr r z_NamespaceLoader.is_packagecCr)Nrrr-rrr r8rz_NamespaceLoader.get_sourcecCstdddddS)Nrzr)T)r:)r;r-rrr r'rz_NamespaceLoader.get_codecCrr#rr$rrr r%r&z_NamespaceLoader.create_modulecCsdSrGrrprrr 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})rrrxr,r-rrr r.s z_NamespaceLoader.load_modulecCsddlm}||jS)Nr)NamespaceReader)rarrx)rr*rrrr rb's  z$_NamespaceLoader.get_resource_readerN) rrrr rrrr8r'r%r+r.rbrrrr 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_cacheitemsrrrvr{)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_hooksrrrsrr)rChookrrr _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. rN)rrWFileNotFoundErrorrrKeyErrorr)rrCrrrr _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_namerrrsrrrrrr)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) rrrCrnamespace_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)rrCrrrrrv)rrrCrrrrrr 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_distributionsrGr)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|]}|fVqdSrGrrqrrr rJsz&FileFinder.__init__..rprN) r_loadersrCr[rErrW _path_mtimeset _path_cache_relaxed_path_cache)rrCloader_detailsloadersrrrr r s    zFileFinder.__init__cCs d|_dS)zInvalidate the directory mtime.rN)rrTrrr rrVzFileFinder.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)rrrsrtrrr)rrrrrr rs zFileFinder.find_loadercCs|||}t||||dS)Nr)r)rrrrCsmslrrrrr 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. Frprmrr Nz trying {}) verbosityzpossible namespace for {})rwrOrCrrWrerPr _fill_cacherrrrrErrUrrXr~rrrr)rrr is_namespace tail_modulercache cache_module base_pathrrr 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.r rpr]cSsh|]}|qSr)r)rfnrrr r Psz)FileFinder._fill_cache..N)rCrlistdirrWrPermissionErrorNotADirectoryErrorrrrrrrr_raddrr) rrCcontentslower_suffix_contentsrrrrrnew_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 supportedrI)rXrrIrrrr path_hook_for_FileFinder\s z6FileFinder.path_hook..path_hook_for_FileFinderr)rrrrrr path_hookRs zFileFinder.path_hookcCr)NzFileFinder({!r}))r_rCrTrrr rdrzFileFinder.__repr__rG)rrrrr rrrrrrrrrrrrrr 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__)getrrmrdr 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_suffixesrdrrmr) extensionssourcebytecoderrr rs  rcCs|adSrG)r)_bootstrap_modulerrr _set_bootstrap_modulesrcCs2t|t}tjtj|gtjt dS)z)Install the path-based import components.N) rrrrrrr meta_pathr?r)rsupported_loadersrrr _installsr)r\rG)NNN)rr)T)Trrrrerrrrrrntrrposixr3r=rr;r@_pathseps_with_colonr%_CASE_INSENSITIVE_PLATFORMS_BYTES_KEYrrrr%r+r-rErMrOrTrUrXr[rltype__code__rr#rr"r(rBrrrr?rrrDEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESrrrrrrrrrrrrrrobjectrrrrr/rIrdrmr]rvrrrrrrrrrrr s            G(  !    IC2-5E1