U &.e@sdZddladdlZddladdlZddlZtjdkZerLddlZ ddl Z nddl Z erbddgZ ndgZ e dZ ee Zde Z dde DZd Zd ZeeZd d Zd dZddZddZerddZnddZddZddZddZddZddZerd d!Znd"d!Zdd$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.ddd.d/d0Z/d1d2Z0d3d4Z1d5d6Z2d7d8Z3d9d:Z4d;d<Z5d=d>Z6d?d@Z7dAdBZ8ddCdDZ9ddEdFZ:ddHdIZ;dJdKZdde>dLdMdNZ?GdOdPdPZ@GdQdRdRZAGdSdTdTeAZBGdUdVdVZCGdWdXdXeCeBZDGdYdZdZeCeAZEgZFGd[d\d\eCeAZGGd]d^d^ZHGd_d`d`ZIGdadbdbZJGdcddddZKddedfZLdgdhZMdidjZNdkdlZOdmdndodpdqdrdsdtdudvdwdxdydzd{d|d}ZPd~dZQdS)a^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:.0srr5/usr/lib64/python3.8/importlib/_bootstrap_external.py /sr )win)cygwindarwincs<tjtr0tjtrdndfdd}ndd}|S)N PYTHONCASEOKs PYTHONCASEOKcs tjkS)5True if filenames must be checked case-insensitively.)_osenvironrkeyrr _relax_case@sz%_make_relax_case.._relax_casecSsdS)rFrrrrr rDs)sysplatform startswith_CASE_INSENSITIVE_PLATFORMS#_CASE_INSENSITIVE_PLATFORMS_STR_KEY)rrrr _make_relax_case9s  rcCst|d@ddS)z*Convert a 32-bit integer to little-endian.little)intto_bytes)xrrr _pack_uint32Jsr#cCs t|dS)z/Convert 4 bytes in little-endian to an integer.rr from_bytesdatarrr _unpack_uint32Osr(cCs t|dS)z/Convert 2 bytes in little-endian to an integer.rr$r&rrr _unpack_uint16Tsr)cGs|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().rrrcSsg|]}|r|tqSrrstrippath_separatorsr prrr rs_path_join..) lenmapr_path_splitrootrpath_sep_tupleendswithr-r.path_sepcasefoldappendjoin) path_partsrootpathZnew_roottailrrr _path_join[s*     r@cGstdd|DS)r*cSsg|]}|r|tqSrr,)r partrrr r1{sr2)r8r;)r<rrr r@ys csBtfddtD}|dkr&dfSd||ddfS)z Replacement for os.path.split().c3s|]}|VqdSN)rfindr/r>rr sz_path_split..rrNr+)maxr.)r>irrDr _path_splitsrHcCs t|S)z~Stat the path. Made a separate function to make it easier to override in experiments (e.g. cache stat results). )rstatrDrrr _path_statsrJcCs2z t|}Wntk r"YdSX|jd@|kS)z1Test whether the path is the specified mode type.Fi)rJOSErrorst_mode)r>mode stat_inforrr _path_is_mode_types  rOcCs t|dS)zReplacement for os.path.isfile.i)rOrDrrr _path_isfilesrPcCs|s t}t|dS)zReplacement for os.path.isdir.i@)rgetcwdrOrDrrr _path_isdirsrRcCs>|sdSt|ddd}t|dko<|dp<|dS)Replacement for os.path.isabs.Frrrr+z\\)rr5replacer3rr7)r>r=rrr _path_isabssrUcCs |tS)rS)rr.rDrrr rUsc Csd|t|}t|tjtjBtjB|d@}z2t|d}| |W5QRXt ||Wn:t k rzt |Wnt k rYnXYnXdS)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.{}.{}rVwbN) formatidropenO_EXCLO_CREATO_WRONLY_ioFileIOwriterTrKunlink)r>r'rMpath_tmpfdfilerrr _write_atomicsrfiU rs __pycache__zopt-z.pyz.pyc) optimizationc CsX|dk r4tdt|dk r(d}t||r0dnd}t|}t|\}}|d\}}}tj j } | dkrrt dd |r~|n||| g} |dkrtj jdkrd}ntj j}t|}|dkr|std |d | t|} | td} tjdk rLt|stt|}|dd kr8|dtkr8|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{}.{}{}rrg) _warningswarnDeprecationWarning TypeErrorrfspathrH rpartitionrimplementation cache_tagNotImplementedErrorr;flagsoptimizestrisalnum ValueErrorrY_OPTBYTECODE_SUFFIXESpycache_prefixrUr@rQr.lstrip_PYCACHE) r>debug_overriderimessageheadr?basesepresttagalmost_filenamefilenamerrr cache_from_sourcebsH       rc Cs.tjjdkrtdt|}t|\}}d}tjdk rftjt }| |t rf|t |d}d}|st|\}}|t krtt d||d}|dkrtd|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. NrkFTz not bottom-level directory in rj>rgzexpected only 2 or 3 dots in rrgz5optimization portion of filename does not start with zoptimization level z is not an alphanumeric valuer)rrrrsrtrrprHr|r-r.rr8r3r~rycountrsplitrzrx partitionr@SOURCE_SUFFIXES) r>rpycache_filenamefound_in_pycache_prefix stripped_pathpycache dot_countri opt_level base_filenamerrr source_from_caches4          rc Cs~t|dkrdS|d\}}}|r8|dddkr<|Sz t|}Wn$ttfk rl|dd}YnXt|rz|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. rNrjpy)r3rqlowerrrtryrP) bytecode_pathr_ extension source_pathrrr _get_sourcefiles  rcCsJ|ttr0z t|WStk r,YqFXn|ttrB|SdSdSrB)r7tuplerrrtr{)rrrr _get_cacheds rcCs4zt|j}Wntk r&d}YnX|dO}|S)z3Calculate the mode permissions for a bytecode file.rV)rJrLrK)r>rMrrr _calc_modes  rcsDdfdd }z tj}Wntk r4dd}YnX|||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. NcsB|dkr|j}n |j|kr0td|j|f|d||f||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)newoldrTrrr _wraps z_check_name.._wrap)N) _bootstrapr NameError)rrrrrr _check_names  rcCs<||\}}|dkr8t|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_loaderr3rlrmrY ImportWarning)rfullnameloaderportionsmsgrrr _find_module_shims rcCs|dd}|tkr) marshalloads isinstance _code_typerr_imp_fix_co_filenamerrY)r'rrrcoderrr _compile_bytecode~s     rcCsFtt}|td|t||t||t||S)z+Produce the data for a timestamp-based pyc.r bytearrayrextendr#rdumps)rmtimerr'rrr _code_to_timestamp_pycs rTcCs@tt}d|d>B}|t||||t||S)z&Produce the data for a hash-based pyc.r+r)rrcheckedr'rurrr _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)tokenizer_BytesIOreadlinedetect_encodingIncrementalNewlineDecoderdecode) source_bytesrsource_bytes_readlineencodingnewline_decoderrrr decode_sources    rrsubmodule_search_locationsc Cs|dkr get_filenameoriginT is_packager)rrrrrpr ModuleSpec _set_fileattr_get_supported_file_loadersr7rr _POPULATErrrHr:) rlocationrrspec loader_classsuffixesrdirnamerrr 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}\DebugFcCs8zttj|WStk r2ttj|YSXdSrB)_winregOpenKeyHKEY_CURRENT_USERrKHKEY_LOCAL_MACHINE)clsrrrr _open_registrysz$WindowsRegistryFinder._open_registryc Csr|jr|j}n|j}|j|dtjddd}z&||}t|d}W5QRXWnt k rlYdSX|S)Nz%d.%drg)r sys_versionr) DEBUG_BUILDREGISTRY_KEY_DEBUG REGISTRY_KEYrYr version_inforr QueryValuerK)rr registry_keyrhkeyfilepathrrr _search_registrys z&WindowsRegistryFinder._search_registryNcCsz||}|dkrdSz t|Wntk r8YdSXtD]4\}}|t|r@tj|||||d}|Sq@dS)Nr)rrJrKrr7rrspec_from_loader)rrr>targetrrrrrrr find_specs  zWindowsRegistryFinder.find_speccCs"|||}|dk r|jSdSdS)zlFind module named in the registry. This method is deprecated. Use exec_module() instead. Nrrrrr>rrrr find_module's z!WindowsRegistryFinder.find_module)NN)N) rrrrr rr classmethodrrrrrrrr 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+rjrrg__init__)rHrrrq)rrr filename_base tail_namerrr r:sz_LoaderBasics.is_packagecCsdSz*Use default semantics for module creation.Nrrrrrr create_moduleBsz_LoaderBasics.create_modulecCs8||j}|dkr$td|jtt||jdS)zExecute the module.Nz4cannot load module {!r} when get_code() returns None)get_coderrrYr_call_with_frames_removedexecr)rmodulerrrr exec_moduleEs  z_LoaderBasics.exec_modulecCs t||S)zThis module is deprecated.)r_load_module_shimrrrrr load_moduleMsz_LoaderBasics.load_moduleN)rrrrrrr"r%rrrr r5s 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)rKrr>rrr path_mtimeTszSourceLoader.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'rrr path_stats\s 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_bytecodejszSourceLoader._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)rr>r'rrr r*tszSourceLoader.set_datac CsR||}z||}Wn0tk rH}ztd|d|W5d}~XYnXt|S)z4Concrete implementation of InspectLoader.get_source.z'source not available through get_data()rN)rget_datarKrr)rrr>rexcrrr get_source{s 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_inheritrv)rrcompile)rr'r>r0rrr source_to_codes zSourceLoader.source_to_codec Cs"||}d}d}d}d}d}z t|}Wntk rDd}Yn0Xz||} Wntk rjYn Xt| d}z||} Wntk rYnX||d} zt| || } t| dd} | d@dk}|r$| d @dk}t j d kr8|st j d kr8||}t t |}t | ||| nt| || d || Wnttfk rTYn Xtd ||t| |||dS|dkr||}|||}td|tjs|dk r|dk r|r|dkrt |}t|||} nt||t|} z|||| Wntk rYnX|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+rrgneveralwayssizez {} matches {})rrrzcode object from {})rrrtr)rKr r-r memoryviewrcheck_hash_based_pycsr_RAW_MAGIC_NUMBERrrrrrrrr3rdont_write_bytecoderrr3r,)rrrrrr hash_based check_sourcerstr'rru bytes_data code_objectrrr rs               zSourceLoader.get_codeN) rrrr(r)r,r*r/r3rrrrr r&Rs  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)rrr>rrr rszFileLoader.__init__cCs|j|jko|j|jkSrB __class__rrotherrrr __eq__s  zFileLoader.__eq__cCst|jt|jASrBhashrr>rrrr __hash__szFileLoader.__hash__cstt||S)zdLoad a module from a file. This method is deprecated. Use exec_module() instead. )superr@r%r$rBrr r%s zFileLoader.load_modulecCs|jSz:Return the path to the source file as found by the finder.rDr$rrr rszFileLoader.get_filenamec Csft|ttfr:tt|}|W5QRSQRXn(t|d}|W5QRSQRXdS)z'Return the data from path as raw bytes.rN)rr&ExtensionFileLoaderr_ open_coderwreadr`)rr>rerrr r-s zFileLoader.get_datacCs||r|SdSrB)rrr!rrr get_resource_readers zFileLoader.get_resource_readercCs tt|jd|}t|dS)NrrM)r@rHr>r_r`rresourcer>rrr open_resourceszFileLoader.open_resourcecCs&||sttt|jd|}|SNr) is_resourceFileNotFoundErrorr@rHr>rSrrr resource_paths zFileLoader.resource_pathcCs(t|kr dStt|jd|}t|S)NFr)r8r@rHr>rPrrr>rrr rW szFileLoader.is_resourcecCsttt|jdSrV)iterrlistdirrHr>rHrrr contents&szFileLoader.contents)rrrrrrErIrr%rr-rRrUrYrWr] __classcell__rrrKr r@s    r@c@s.eZdZdZddZddZdddd Zd S) SourceFileLoaderz>Concrete implementation of SourceLoader using the file system.cCst|}|j|jdS)z!Return the metadata for the path.)rr6)rJst_mtimest_size)rr>r=rrr r).szSourceFileLoader.path_statscCst|}|j|||dS)N_mode)rr*)rrrr'rMrrr r,3sz SourceFileLoader._cache_bytecoderVrbc Cst|\}}g}|r4t|s4t|\}}||qt|D]l}t||}zt|Wq<tk rpYqr'rcparentrr<rAr.rrr r*8s0       zSourceFileLoader.set_dataN)rrrrr)r,r*rrrr r_*sr_c@s eZdZdZddZddZdS)SourcelessFileLoaderz-Loader which handles sourceless file imports.cCsD||}||}||d}t|||tt|dd||dS)Nrr)rr)rr-rrr7)rrr>r'rrrr r[s   zSourcelessFileLoader.get_codecCsdS)z'Return None as there is no source code.Nrr$rrr r/kszSourcelessFileLoader.get_sourceN)rrrrrr/rrrr rhWsrhc@s\eZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ e ddZ dS)rNz]Loader for extension modules. The constructor is designed to work with FileFinder. cCs@||_t|s6ztt|}Wntk r4YnX||_dSrB)rrUr@rrQrKr>rZrrr r|szExtensionFileLoader.__init__cCs|j|jko|j|jkSrBrArCrrr rEs  zExtensionFileLoader.__eq__cCst|jt|jASrBrFrHrrr rIszExtensionFileLoader.__hash__cCs$ttj|}td|j|j|S)z&Create an unitialized extension modulez&extension module {!r} loaded from {!r})rrrcreate_dynamicrrr>)rrr!rrr rsz!ExtensionFileLoader.create_modulecCs$ttj|td|j|jdS)zInitialize an extension modulez(extension module {!r} executed from {!r}N)rrr exec_dynamicrrr>rQrrr r"s zExtensionFileLoader.exec_modulecs$t|jdtfddtDS)z1Return True if the extension module is a package.r+c3s|]}d|kVqdS)rNrr suffix file_namerr rEsz1ExtensionFileLoader.is_package..)rHr>anyEXTENSION_SUFFIXESr$rrmr rs zExtensionFileLoader.is_packagecCsdS)z?Return None as an extension module cannot create a code object.Nrr$rrr rszExtensionFileLoader.get_codecCsdS)z5Return None as extension modules have no source code.Nrr$rrr r/szExtensionFileLoader.get_sourcecCs|jSrLrDr$rrr rsz ExtensionFileLoader.get_filenameN)rrrrrrErIrr"rrr/rrrrrr rNts rNc@sheZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)_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.cCs$||_||_t||_||_dSrB)_name_pathr_get_parent_path_last_parent_path _path_finderrrr> path_finderrrr rsz_NamespacePath.__init__cCs&|jd\}}}|dkrdS|dfS)z>Returns a tuple of (parent-module-name, parent-path-attr-name)rjr)rr>__path__)rrrq)rrgdotmerrr _find_parent_path_namessz&_NamespacePath._find_parent_path_namescCs|\}}ttj||SrB)r|rrmodules)rparent_module_namepath_attr_namerrr rts z_NamespacePath._get_parent_pathcCsPt|}||jkrJ||j|}|dk rD|jdkrD|jrD|j|_||_|jSrB)rrtrurvrrrrrs)r parent_pathrrrr _recalculates  z_NamespacePath._recalculatecCs t|SrB)r[rrHrrr __iter__sz_NamespacePath.__iter__cCs ||SrBr)rindexrrr __getitem__sz_NamespacePath.__getitem__cCs||j|<dSrB)rs)rrr>rrr __setitem__sz_NamespacePath.__setitem__cCs t|SrB)r3rrHrrr __len__sz_NamespacePath.__len__cCs d|jS)Nz_NamespacePath({!r}))rYrsrHrrr __repr__sz_NamespacePath.__repr__cCs ||kSrBrritemrrr __contains__sz_NamespacePath.__contains__cCs|j|dSrB)rsr:rrrr r:sz_NamespacePath.appendN)rrrrrr|rtrrrrrrrr:rrrr rqs  rqc@sPeZdZddZeddZddZddZd d Zd d Z d dZ ddZ dS)_NamespaceLoadercCst||||_dSrB)rqrsrwrrr rsz_NamespaceLoader.__init__cCs d|jS)zsReturn repr for the module. The method is deprecated. The import machinery does the job itself. z)rYr)rr!rrr module_reprsz_NamespaceLoader.module_reprcCsdS)NTrr$rrr rsz_NamespaceLoader.is_packagecCsdS)Nrrr$rrr r/sz_NamespaceLoader.get_sourcecCstdddddS)Nrzr T)r1)r2r$rrr rsz_NamespaceLoader.get_codecCsdSrrrrrr rsz_NamespaceLoader.create_modulecCsdSrBrrQrrr 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})rrrsr#r$rrr r% sz_NamespaceLoader.load_moduleN) rrrrrrrr/rrr"r%rrrr rs rc@sveZdZdZeddZeddZeddZedd Zedd d Z edd dZ edddZ eddZ d S) PathFinderz>Meta path finder for sys.path and package __path__ attributes.cCs@ttjD],\}}|dkr(tj|=qt|dr|qdS)z}Call the invalidate_caches() method on all path entry finders stored in sys.path_importer_caches (where implemented).Ninvalidate_caches)listrpath_importer_cacheitemsrr)rrfinderrrr rs   zPathFinder.invalidate_cachesc CsTtjdk rtjstdttjD],}z||WStk rLYq"Yq"Xq"dS)z.Search sys.path_hooks for a finder for 'path'.Nzsys.path_hooks is empty)r path_hooksrlrmrr)rr>hookrrr _path_hooks%s   zPathFinder._path_hookscCsh|dkr,z t}Wntk r*YdSXztj|}Wn(tk rb||}|tj|<YnX|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)rrQrXrrKeyErrorr)rr>rrrr _path_importer_cache2s  zPathFinder._path_importer_cachecCsRt|dr||\}}n||}g}|dk rrnamespace_pathentryrrrrrr _get_specWs(      zPathFinder._get_speccCsd|dkrtj}||||}|dkr(dS|jdkr\|j}|rVd|_t|||j|_|SdSn|SdS)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)rr>rrrrrq)rrr>rrrrrr rws zPathFinder.find_speccCs|||}|dkrdS|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. Nrrrrr rs zPathFinder.find_modulecOsddlm}|j||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)rrrrrrr rs zPathFinder.find_distributions)N)NN)N) rrrrrrrrrrrrrrrrr rs"       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||_|p6d|_t|jsVtt|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|]}|fVqdSrBrrkrrr rEsz&FileFinder.__init__..rjrN) r_loadersr>rUr@rrQ _path_mtimeset _path_cache_relaxed_path_cache)rr>loader_detailsloadersrrrr rs   zFileFinder.__init__cCs d|_dS)zInvalidate the directory mtime.rN)rrHrrr rszFileFinder.invalidate_cachescCs*||}|dkrdgfS|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)rrrrrr rs zFileFinder.find_loadercCs|||}t||||dS)Nr)r)rrrr>smslrrrrr rs zFileFinder._get_specNc Csd}|dd}zt|jp"tj}Wntk rBd}YnX||jkr\|||_t rr|j }| }n |j }|}||krt |j|}|jD]:\} } d| } t || } t| r|| || |g|Sqt|}|jD]r\} } zt |j|| } Wntk rYdSXtjd| dd|| |krt| r|| || d|Sq|r~td |t|d} |g| _| SdS) zoTry to find a spec for the specified module. Returns the matching spec, or None if not found. FrjrgrrNz trying {}) verbosityzpossible namespace for {})rqrJr>rrQr`rKr _fill_cacherrrrr@rrPrrRryrrrr)rrr is_namespace tail_modulercache cache_module base_pathrlr init_filename full_pathrrrr rsP           zFileFinder.find_specc Cs|j}zt|pt}Wntttfk r:g}YnXtj dsTt ||_ nJt }|D]8}| d\}}}|rd ||}n|}||q^||_ tj trdd|D|_dS)zDFill the cache of potential modules and packages for this directory.r rjrWcSsh|] }|qSr)r)r fnrrr r *sz)FileFinder._fill_cache..N)r>rr\rQrXPermissionErrorNotADirectoryErrorrrrrrrrYraddrr) rr>r]lower_suffix_contentsrrrzrlnew_namerrr r s"     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|fS)z-Path hook for importlib.machinery.FileFinder.zonly directories are supportedrD)rRrrDrrrr path_hook_for_FileFinder6s z6FileFinder.path_hook..path_hook_for_FileFinderr)rrrrrr path_hook,s zFileFinder.path_hookcCs d|jS)NzFileFinder({!r}))rYr>rHrrr r>szFileFinder.__repr__)N)rrrrrrrrrrrrrrrrrrr rs  3 rcCs|d}|d}|sB|r$|j}n||kr8t||}n t||}|sTt|||d}z$||d<||d<||d<||d<Wntk rYnXdS)N __loader____spec__r__file__ __cached__)getrrhr_r Exception)nsrpathname cpathnamerrrrr _fix_up_moduleDs"     rcCs*tttf}ttf}ttf}|||gS)z_Returns a list of file-based module loaders. Each item is a tuple (loader, suffixes). )rN_alternative_architecturesrextension_suffixesr_rrhr{) extensionssourcebytecoderrr r[src Cs|atjatjatjt}dD]0}|tjkr8t|}n tj|}t|||qddgfdddgff}|D]X\}}|d}|tjkrtj|}qqjzt|}WqWqjtk rYqjYqjXqjtdt|d|t|d |t|d d |t|d d d|Dtd} t|d| td} t|d| |dkrXtd} t|d| t|dt t t t |dkrtddt krdt_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. )r_rlbuiltinsrposixrntrrzimportlib requires posix or ntrr8r.r_pathseps_with_coloncSsh|]}d|qSrrrrrr r sz_setup.._thread_weakrefwinregrrz.pywz_d.pydTN)rrrr}r_builtin_from_namerrr;rrprrrrr:rr) _bootstrap_module self_module builtin_namebuiltin_module os_details builtin_osr.r8 os_module thread_moduleweakref_module winreg_modulerrr _setupfsL                      rcCs2t|t}tjtj|gtjt dS)z)Install the path-based import components.N) rrrrrrr meta_pathr:r)rsupported_loadersrrr _installsr-arm-linux-gnueabihf.-armeb-linux-gnueabihf.-mips64-linux-gnuabi64.-mips64el-linux-gnuabi64.-powerpc-linux-gnu.-powerpc-linux-gnuspe.-powerpc64-linux-gnu.-powerpc64le-linux-gnu.-arm-linux-gnueabi.-armeb-linux-gnueabi.-mips64-linux-gnu.-mips64el-linux-gnu.-ppc-linux-gnu.-ppc-linux-gnuspe.-ppc64-linux-gnu.-ppc64le-linux-gnu.)rrrrrrrrrrrrrrrrcCsF|D]<}tD].\}}||kr|||||Sqq|S)zAdd a suffix with an alternative architecture name to the list of suffixes so an extension built with the default (upstream) setting is loadable with our Pythons ) _ARCH_MAPrr:rT)rrloriginal alternativerrr rs r)rV)N)NNN)rr)T)N)N)Rrrr_rrlrr _MS_WINDOWSrrrrr.r8rr6r;rr%_CASE_INSENSITIVE_PLATFORMS_BYTES_KEYrrr#r(r)r@rHrJrOrPrRrUrftype__code__rr!rr r%r9r~rzrr{DEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESrrrrrrrrrrrrrrobjectrrrrr&r@r_rhrprNrqrrrrrrrrrrrrr s            G(  !  D@H-:?*  A