a DOg@sdZddladdlZddladdlZddlZtjdkZerLddlZ ddl Z nddl Z erbddgZ ndgZ e dde Ds~Je dZee Zde Z d d e DZd Zd ZeeZd dZddZddZddZerddZnddZddZddZddZddZd d!Zer$d"d#Z nd$d#Z dod&d'Z!e"e!j#Z$d(%d)d*d+Z&e'(e&d*Z)d,Z*d-Z+d.gZ,d/gZ-e-Z.Z/dpdd0d1d2Z0d3d4Z1d5d6Z2d7d8Z3d9d:Z4d;d<Z5d=d>Z6d?d@Z7dAdBZ8dCdDZ9dqdEdFZ:drdGdHZ;dsdJdKZZ?dtde?dNdOdPZ@GdQdRdRZAGdSdTdTZBGdUdVdVeBZCGdWdXdXZDGdYdZdZeDeCZEGd[d\d\eDeBZFgZGGd]d^d^eDeBZHGd_d`d`ZIGdadbdbZJGdcddddZKGdedfdfZLdudgdhZMdidjZNdkdlZOdmdnZPdS)va^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|dkVqdSNlen.0sepr B/opt/alt/python39/lib64/python3.9/importlib/_bootstrap_external.py +r cCsh|]}d|qS:r r sr r r /rr)win)cygwindarwincs<tjtr0tjtrdndfdd}ndd}|S)N PYTHONCASEOKs PYTHONCASEOKcstjj otjvS)z^True if filenames must be checked case-insensitively and ignore environment flags are not set.)sysflagsignore_environment_osenvironr keyr r _relax_case@sz%_make_relax_case.._relax_casecSsdS)z5True if filenames must be checked case-insensitively.Fr r r r r r Ds)rplatform startswith_CASE_INSENSITIVE_PLATFORMS#_CASE_INSENSITIVE_PLATFORMS_STR_KEY)r r rr _make_relax_case9s  r%cCst|d@ddS)z*Convert a 32-bit integer to little-endian.little)intto_bytes)xr r r _pack_uint32Jsr,cCst|dksJt|dS)z/Convert 4 bytes in little-endian to an integer.r'r(rr) from_bytesdatar r r _unpack_uint32Osr1cCst|dksJt|dS)z/Convert 2 bytes in little-endian to an integer.r(r-r/r r r _unpack_uint16Tsr3cGs|sdSt|dkr|dSd}g}ttj|D]z\}}|tsL|trf|tpX|}t |g}q0|dr| | kr|}|g}q| |q0|p|}| |q0dd|D}t|dkr|ds|t S|t |S)Replacement for os.path.join().rrrrcSsg|]}|r|tqSr rstrippath_separatorsr pr r r rr_path_join..) rmapr_path_splitrootr"path_sep_tupleendswithr6r7path_sepcasefoldappendjoin) path_partsrootpathZnew_roottailr r r _path_join[s*     rHcGstdd|DS)r4cSsg|]}|r|tqSr r5)r partr r r r:{sr;)r@rC)rDr r r rHys csBtfddtD}|dkr&dfSd||ddfS)z Replacement for os.path.split().c3s|]}|VqdSN)rfindr8rFr r r rz_path_split..rrNr)maxr7)rFir rLr _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). )rstatrLr r r _path_statsrQcCs0z t|}Wnty YdS0|jd@|kS)z1Test whether the path is the specified mode type.Fi)rQOSErrorst_mode)rFmode stat_infor r r _path_is_mode_types   rVcCs t|dS)zReplacement for os.path.isfile.i)rVrLr r r _path_isfilesrWcCs|s t}t|dS)zReplacement for os.path.isdir.i@)rgetcwdrVrLr r r _path_isdirsrYcCs>|sdSt|ddd}t|dko<|dp<|dS)Replacement for os.path.isabs.Frrrrz\\)rr=replacerr"r?)rFrEr r r _path_isabssr\cCs |tS)rZ)r"r7rLr r r r\sc Csd|t|}t|tjtjBtjB|d@}zFt|d}| |Wdn1s^0Yt ||Wn6t yzt |Wnt yYn0Yn0dS)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)rFr0rTpath_tmpfdfiler r r _write_atomics(  rmia r2r(s __pycache__zopt-z.pyz.pyc) optimizationc CsX|dur4tdt|dur(d}t||r0dnd}t|}t|\}}|d\}}}tj j } | durrt dd |r~|n||| g} |durtj jdkrd}ntj j}t|}|dkr|std |d | t|} | td} tjdurLt|stt|}|dd kr8|dtvr8|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{}.{}{}rr2) _warningswarnDeprecationWarning TypeErrorrfspathrO rpartitionrimplementation cache_tagNotImplementedErrorrCroptimizestrisalnum ValueErrorr`_OPTBYTECODE_SUFFIXESpycache_prefixr\rHrXr7lstrip_PYCACHE) rFdebug_overrideromessageheadrGbaser resttagalmost_filenamefilenamer r r cache_from_sourceisH       rc Cs.tjjdurtdt|}t|\}}d}tjdurftjt }| |t rf|t |d}d}|st|\}}|t krtt d||d}|dvrtd|n\|d kr|dd d }| tstd 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>r2zexpected only 2 or 3 dots in rr2z5optimization portion of filename does not start with zoptimization level z is not an alphanumeric valuer)rrxryrzrrvrOrr6r7r"r@rrr~countrsplitrr} partitionrHSOURCE_SUFFIXES) rFrpycache_filenamefound_in_pycache_prefix stripped_pathpycache dot_countro opt_level base_filenamer r r source_from_caches<          rc Cs|t|dkrdS|d\}}}|r8|dddkr<|Sz t|}Wn"ttfyj|dd}Yn0t|rx|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)rrwlowerrrzr~rW) bytecode_pathr_ extension source_pathr r r _get_sourcefiles  rcCsH|ttr.z t|WSty*YqD0n|ttr@|SdSdSrJ)r?tuplerrrzr)rr r r _get_cacheds  rcCs2zt|j}Wnty$d}Yn0|dO}|S)z3Calculate the mode permissions for a bytecode file.r])rQrSrR)rFrTr r r _calc_modes   rcsBdfdd }z tj}Wnty2dd}Yn0|||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|kr0td|j|f|d||g|Ri|S)Nzloader for %s cannot handle %sname)r ImportError)selfrargskwargsmethodr r _check_name_wrapper s z(_check_name.._check_name_wrappercSs8dD] }t||rt||t||q|j|jdS)N) __module____name__ __qualname____doc__)hasattrsetattrgetattr__dict__update)newoldr[r r r _wraps z_check_name.._wrap)N) _bootstrapr NameError)rrrr rr _check_names   rcCs<||\}}|dur8t|r8d}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(). Nz,Not importing directory {}: missing __init__r) find_loaderrrrrsr` ImportWarning)rfullnameloaderportionsmsgr r r _find_module_shims rcCs|dd}|tkr@d|d|}td|t|fi|t|dkrjd|}td|t|t|dd}|d @rd |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_messagerrEOFErrorr1)r0r exc_detailsmagicrrr r r _classify_pyc0s     rcCsxt|dd|d@kr>d|}td|t|fi||durtt|dd|d@krttd|fi|dS)aValidate a pyc against the source last-modified time. *data* is the contents of the pyc file. (Only the first 16 bytes are required.) *source_mtime* is the last modified timestamp of the source file. *source_size* is None or the size of the source file in bytes. *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. An ImportError is raised if the bytecode is stale. r r&zbytecode is stale for rNr)r1rrr)r0 source_mtime source_sizerrrr r r _validate_timestamp_pycQs  rcCs*|dd|kr&td|fi|dS)aValidate a hash-based pyc by checking the real source hash against the one in the pyc header. *data* is the contents of the pyc file. (Only the first 16 bytes are required.) *source_hash* is the importlib.util.source_hash() of the source file. *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. An ImportError is raised if the bytecode is stale. rrz.hash in bytecode doesn't match hash of source N)r)r0 source_hashrrr r r _validate_hash_pycms rcCsPt|}t|tr8td||dur4t|||Std |||ddS)z#Compile bytecode as found in a pyc.zcode object from {!r}NzNon-code object in {!r}rrF) marshalloads isinstance _code_typerr_imp_fix_co_filenamerr`)r0rrrcoder r r _compile_bytecodes     rcCsFtt}|td|t||t||t||S)z+Produce the data for a timestamp-based pyc.r) bytearrayrextendr,rdumps)rmtimerr0r r r _code_to_timestamp_pycs rTcCsPtt}d|d>B}|t|t|dks2J|||t||S)z&Produce the data for a hash-based pyc.rr)rrrr,rrr)rrcheckedr0rr 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)tokenizerfBytesIOreadlinedetect_encodingIncrementalNewlineDecoderdecode) source_bytesrsource_bytes_readlineencodingnewline_decoderr r r decode_sources    rrsubmodule_search_locationsc Cs |dur:d}t|drDz||}WqDty6YqD0n t|}tj|||d}d|_|durtD]*\}}| t |rh|||}||_ qqhdS|t urt|drz| |}WntyYq0|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 ModuleSpec _set_fileattr_get_supported_file_loadersr?rr _POPULATErrrOrB) rlocationrrspec loader_classsuffixesrdirnamer r r spec_from_file_locations>          rc@sPeZdZdZdZdZdZeddZeddZ edd d Z edd d Z d 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}\DebugFcCs6zttj|WSty0ttj|YS0dSrJ)winregOpenKeyHKEY_CURRENT_USERrRHKEY_LOCAL_MACHINE)clsrr r r _open_registrys z$WindowsRegistryFinder._open_registrycCs|jr|j}n|j}|j|dtjddd}z:||}t|d}Wdn1s^0YWnt y~YdS0|S)Nz%d.%dr2)r sys_versionr) DEBUG_BUILDREGISTRY_KEY_DEBUG REGISTRY_KEYr`r version_inforr QueryValuerR)rr registry_keyrhkeyfilepathr r r _search_registrys . z&WindowsRegistryFinder._search_registryNcCsx||}|durdSz t|Wnty6YdS0tD]4\}}|t|r>tj|||||d}|Sq>dS)Nr)rrQrRrr?rrspec_from_loader)rrrFtargetrrrrr r r find_specs   zWindowsRegistryFinder.find_speccCs"|||}|dur|jSdSdS)zlFind module named in the registry. This method is deprecated. Use exec_module() instead. NrrrrrFrr r r find_module.s z!WindowsRegistryFinder.find_module)NN)N) rrrrr r r  classmethodrrrrr 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'.rrprr2__init__)rOrrrw)rrr filename_base tail_namer r r rAsz_LoaderBasics.is_packagecCsdSz*Use default semantics for module creation.Nr rrr r r create_moduleIsz_LoaderBasics.create_modulecCs8||j}|dur$td|jtt||jdS)zExecute the module.Nz4cannot load module {!r} when get_code() returns None)get_coderrr`r_call_with_frames_removedexecr)rmodulerr r r exec_moduleLs  z_LoaderBasics.exec_modulecCs t||S)zThis module is deprecated.)r_load_module_shimrrr r r load_moduleTsz_LoaderBasics.load_moduleN)rrrrrr r%r(r r r r r<s rc@sJeZdZddZddZddZddZd d Zd d d dZddZ dS) SourceLoadercCstdS)zOptional method that returns the modification time (an int) for the specified path (a str). Raises OSError when the path cannot be handled. N)rRrrFr 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)r+r*r r r path_statscs 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_pathr0r r r _cache_bytecodeqszSourceLoader._cache_bytecodecCsdS)zOptional method which writes data (bytes) to a file path (a str). Implementing this method allows for the writing of bytecode files. Nr )rrFr0r r r r-{szSourceLoader.set_datac CsT||}z||}Wn2tyJ}ztd|d|WYd}~n d}~00t|S)z4Concrete implementation of InspectLoader.get_source.z'source not available through get_data()rN)rget_datarRrr)rrrFrexcr 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)rr0rFr3r r r source_to_codes zSourceLoader.source_to_codec Cs||}d}d}d}d}d}z t|}WntyBd}Yn*0z||} WntyfYn0t| d}z||} WntyYn0||d} zt| || } t| dd} | d@dk}|r| d @dk}t j d kr2|st j d kr2||}t t |}t | ||| nt| || d || WnttfyLYn 0td ||t| |||dS|dur||}|||}td|tjs|dur|dur|r|durt |}t|||} nt||t|} z|||| WntyYn0|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 {})rrrzr,rRr)r0r memoryviewrcheck_hash_based_pycsr_RAW_MAGIC_NUMBERrrrrrrrr6rdont_write_bytecoderrrr/)rrrrrr hash_based check_sourcerstr0rr bytes_data code_objectr r r r!s                  zSourceLoader.get_codeN) rrrr+r,r/r-r2r6r!r r r r r)Ys  r)cs|eZdZdZddZddZddZefdd Zed d Z d d Z eddZ ddZ ddZ ddZddZZS) 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)rrrFr r r rszFileLoader.__init__cCs|j|jko|j|jkSrJ __class__rrotherr r r __eq__s  zFileLoader.__eq__cCst|jt|jASrJhashrrFrr r r __hash__szFileLoader.__hash__cstt||S)zdLoad a module from a file. This method is deprecated. Use exec_module() instead. )superrCr(r'rEr r r(s zFileLoader.load_modulecCs|jSz:Return the path to the source file as found by the finder.rLr'r r r rszFileLoader.get_filenamecCs~t|ttfrFtt|}|WdS1s:0Yn4t|d}|WdS1sp0YdS)z'Return the data from path as raw bytes.Nr)rr)ExtensionFileLoaderrf open_coder|readrg)rrFrlr r r r0 s (zFileLoader.get_datacCs||r|SdSrJ)rrr$r r r get_resource_readers zFileLoader.get_resource_readercCs tt|jd|}t|dS)NrrP)rHrOrFrfrgrresourcerFr r r open_resourceszFileLoader.open_resourcecCs&||sttt|jd|}|SNr) is_resourceFileNotFoundErrorrHrOrFrVr r r resource_path!s zFileLoader.resource_pathcCs(t|vr dStt|jd|}t|S)NFr)r@rHrOrFrWrrrFr r r rZ'szFileLoader.is_resourcecCsttt|jdSrY)iterrlistdirrOrFrKr r r contents-szFileLoader.contents)rrrrrrHrLrr(rr0rUrXr\rZr` __classcell__r r rNr rCs    rCc@s.eZdZdZddZddZdddd Zd S) SourceFileLoaderz>Concrete implementation of SourceLoader using the file system.cCst|}|j|jdS)z!Return the metadata for the path.)rr9)rQst_mtimest_size)rrFr@r r r r,5szSourceFileLoader.path_statscCst|}|j|||dS)N_mode)rr-)rrrr0rTr r r r/:sz SourceFileLoader._cache_bytecoder]rec Cst|\}}g}|r4t|s4t|\}}||qt|D]h}t||}zt|Wq<tynYq||_t|s4ztt|}Wnty2Yn0||_dSrJ)rr\rHrrXrRrFr]r r r rs zExtensionFileLoader.__init__cCs|j|jko|j|jkSrJrDrFr r r rHs  zExtensionFileLoader.__eq__cCst|jt|jASrJrIrKr r r rLszExtensionFileLoader.__hash__cCs$ttj|}td|j|j|S)z&Create an unitialized extension modulez&extension module {!r} loaded from {!r})rr"rcreate_dynamicrrrF)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_dynamicrrrFrTr r r r%szExtensionFileLoader.exec_modulecs$t|jdtfddtDS)z1Return True if the extension module is a package.rc3s|]}d|kVqdS)rNr r suffix file_namer r r sz1ExtensionFileLoader.is_package..)rOrFanyEXTENSION_SUFFIXESr'r rpr rs zExtensionFileLoader.is_packagecCsdS)z?Return None as an extension module cannot create a code object.Nr r'r r r r!szExtensionFileLoader.get_codecCsdS)z5Return None as extension modules have no source code.Nr r'r r r r2szExtensionFileLoader.get_sourcecCs|jSrOrLr'r r r rsz ExtensionFileLoader.get_filenameN)rrrrrrHrLr r%rr!r2rrr r r r rQ{s rQc@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_finderr r r rs z_NamespacePath.__init__cCs&|jd\}}}|dkrdS|dfS)z>Returns a tuple of (parent-module-name, parent-path-attr-name)rpr)rrF__path__)rurw)rrjdotmer r r _find_parent_path_namessz&_NamespacePath._find_parent_path_namescCs|\}}ttj||SrJ)rrrmodules)rparent_module_namepath_attr_namer r r rws z_NamespacePath._get_parent_pathcCsdt|}||jks"|j|jkr^||j|}|durP|jdurP|jrP|j|_ ||_|j|_|j SrJ) rrwrxryrzr{rurrrv)r parent_pathrr r r _recalculates z_NamespacePath._recalculatecCs t|SrJ)r^rrKr r r __iter__sz_NamespacePath.__iter__cCs ||SrJr)rindexr r r __getitem__sz_NamespacePath.__getitem__cCs||j|<dSrJ)rv)rrrFr r r __setitem__sz_NamespacePath.__setitem__cCs t|SrJ)rrrKr r r __len__sz_NamespacePath.__len__cCs d|jS)Nz_NamespacePath({!r}))r`rvrKr r r __repr__sz_NamespacePath.__repr__cCs ||vSrJrritemr r r __contains__sz_NamespacePath.__contains__cCs|j|dSrJ)rvrBrr r r rBsz_NamespacePath.appendN)rrrrryrrrwrrrrrrrrBr r r r rts rtc@sPeZdZddZeddZddZddZd d Zd d Z d dZ ddZ dS)_NamespaceLoadercCst||||_dSrJ)rtrvr|r r r rsz_NamespaceLoader.__init__cCs d|jS)zsReturn repr for the module. The method is deprecated. The import machinery does the job itself. z)r`r)rr$r r r module_reprsz_NamespaceLoader.module_reprcCsdS)NTr r'r r r rsz_NamespaceLoader.is_packagecCsdS)Nrr r'r r r r2 sz_NamespaceLoader.get_sourcecCstdddddS)Nrzr#T)r4)r5r'r r r r! sz_NamespaceLoader.get_codecCsdSrr rr r r r sz_NamespaceLoader.create_modulecCsdSrJr rTr r r r%sz_NamespaceLoader.exec_modulecCstd|jt||S)zbLoad a namespace module. This method is deprecated. Use exec_module() instead. z&namespace module loaded with path {!r})rrrvr&r'r r r r(sz_NamespaceLoader.load_moduleN) rrrrrrrr2r!r r%r(r r r r rs rc@sveZdZdZeddZeddZeddZedd Zedd d Z edd dZ edddZ eddZ d S) PathFinderz>Meta path finder for sys.path and package __path__ attributes.cCsNttjD],\}}|dur(tj|=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_cacheitemsrrrtry)rrfinderr r r r(s    zPathFinder.invalidate_cachesc CsRtjdurtjstdttjD]*}z||WStyJYq"Yq"0q"dS)z.Search sys.path_hooks for a finder for 'path'.Nzsys.path_hooks is empty)r path_hooksrrrsrr)rrFhookr r r _path_hooks5s    zPathFinder._path_hookscCsd|dkr*z t}Wnty(YdS0ztj|}Wn&ty^||}|tj|<Yn0|S)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)rrXr[rrKeyErrorr)rrFrr r r _path_importer_cacheBs    zPathFinder._path_importer_cachecCsRt|dr||\}}n||}g}|dur.rprN) r_loadersrFr\rHrrX _path_mtimeset _path_cache_relaxed_path_cache)rrFloader_detailsloadersrr rr rs   zFileFinder.__init__cCs d|_dS)zInvalidate the directory mtime.rN)rrKr r r rszFileFinder.invalidate_cachescCs*||}|durdgfS|j|jp&gfS)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. N)rrr)rrrr r r rs zFileFinder.find_loadercCs|||}t||||dS)Nr)r)rrrrFsmslrrr r r rs zFileFinder._get_specNc Cs~d}|dd}zt|jp"tj}Wnty@d}Yn0||jkrZ|||_t rp|j }| }n |j }|}||vrt |j|}|jD]:\} } d| } t || } t| r|| || |g|Sqt|}|jD]p\} } zt |j|| } WntyYdS0tjd| dd|| |vrt| r|| || d|Sq|rztd |t|d} |g| _| SdS) zoTry to find a spec for the specified module. Returns the matching spec, or None if not found. Frpr2rrNz trying {}) verbosityzpossible namespace for {})rwrQrFrrXrcrRr _fill_cacher rrrrHrrWrrYr~rrrr)rrr is_namespace tail_modulercache cache_module base_pathror init_filename full_pathrr r r rsN            zFileFinder.find_specc Cs|j}zt|pt}Wntttfy8g}Yn0tj dsRt ||_ nJt }|D]8}| d\}}}|rd ||}n|}||q\||_ tj trdd|D|_dS)zDFill the cache of potential modules and packages for this directory.rrpr^cSsh|] }|qSr )r)r fnr r r r:rz)FileFinder._fill_cache..N)rFrr_rXr[PermissionErrorNotADirectoryErrorrr!r"rrrr`raddr#r) rrFr`lower_suffix_contentsrrrronew_namer r r rs"     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|std|d|gRS)z-Path hook for importlib.machinery.FileFinder.zonly directories are supportedrL)rYrrLrrr r path_hook_for_FileFinderFs z6FileFinder.path_hook..path_hook_for_FileFinderr )rrrr rr path_hook<s zFileFinder.path_hookcCs d|jS)NzFileFinder({!r}))r`rFrKr r r rNszFileFinder.__repr__)N)rrrrrrrrrrrrrrrr r r r rs  3 rcCs|d}|d}|sB|r$|j}n||kr8t||}n t||}|sTt|||d}z$||d<||d<||d<||d<WntyYn0dS)N __loader____spec__r__file__ __cached__)getrrkrbr Exception)nsrpathname cpathnamerrr r r _fix_up_moduleTs"      rcCs&ttf}ttf}ttf}|||gS)z_Returns a list of file-based module loaders. Each item is a tuple (loader, suffixes). )rQrextension_suffixesrbrrkr) extensionssourcebytecoder r r rks rc Cs|atjatjatjt}ddgfdddgff}|D]l\}}tdd|DsRJ|d}|tjvrttj|}qq4zt|}WqWq4tyYq4Yq40q4tdt|d |t|d |t|d d |t|d dd|Dgd}|dkr| d|D]4}|tjvr&t|} n tj|} t||| q t|dt t t|dkrt ddt vrdt_dS)zSetup the path-based importers for importlib by importing needed built-in modules and injecting them into the global namespace. Other components are extracted from the core bootstrap module. posixrntrcss|]}t|dkVqdSrrrr r r r rz_setup..rzimportlib requires posix or ntrr@r7r_pathseps_with_coloncSsh|]}d|qSrr rr r r rrz_setup..)rfrrrrr z.pywz_d.pydTN)rrrrrall_builtin_from_namerrrCrBr%rsrrrrr ) _bootstrap_module self_module os_details builtin_osr7r@ os_module builtin_names builtin_namebuiltin_moduler r r _setupvsF                  rcCs2t|t}tjtj|gtjt dS)z)Install the path-based import components.N) rrrrrrr meta_pathrBr)rsupported_loadersr r r _installsr)r])N)NNN)rr)T)N)N)Qrrrfrrrrr! _MS_WINDOWSrrrrr7rr@rr>rCrr$%_CASE_INSENSITIVE_PLATFORMS_BYTES_KEYr#r%r,r1r3rHrOrQrVrWrYr\rmtype__code__rr*rr)r.r<rrrrDEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESrrrrrrrrrrrrrrobjectrrrrr)rCrbrkrsrQrtrrrrrrrr r r r s           G(  !  D@H-:E*  9