î e f!Sã@sädZd£Zdd„Zdd„Zdd „Zd d „Zd d „Zdd„Zdd„Zdd„Z dd„Z ddd„Z dd„Z dd„Z ee jƒZGdd„dƒZiZiZGdd „d eƒZGd!d"„d"ƒZGd#d$„d$ƒZGd%d&„d&ƒZd'd(„Zd)d*„Zd+d,„Zd-jd.d/ƒd0Zejed/ƒZ d1Z!d2gZ"d3gZ#d4gZ$d5d6d7„Z%d8d9„Z&d:d;„Z'd<d=„Z(d>d?d@dA„Z)dBdC„Z*dDdE„Z+dFdG„Z,dHdI„Z-dJdK„Z.d5d5d5dLdM„Z/d5d5d5dNdO„Z0dPdPdQdR„Z1dSdT„Z2dUdV„Z3GdWdX„dXƒZ4GdYdZ„dZƒZ5d[d5d\d5d]d^„Z6e7ƒZ8d5d_d5d`e8dadb„Z9d5d5dcdd„Z:Gdedf„dfƒZ;d5dgdh„Z<Gdidj„djƒZ=Gdkdl„dlƒZ>Gdmdn„dnƒZ?Gdodp„dpƒZ@Gdqdr„dre@ƒZAGdsdt„dtƒZBGdudv„dveBeAƒZCGdwdx„dxeBe@ƒZDgZEGdydz„dzƒZFGd{d|„d|ƒZGGd}d~„d~ƒZHGdd€„d€ƒZIGd�d‚„d‚ƒZJGdƒd„„d„ƒZKd…d†„ZLd‡dˆ„ZMd5d‰dŠ„ZNd‹dŒ„ZOd�ZPePdŽZQd�d�„ZRd‘d’„ZSd5dPd“d”„ZTd•d–„ZUd—d˜„ZVd™dš„ZWd5d5fdPd›dœ„ZXd�dž„ZYdŸd „ZZd¡d¢„Z[d5S)¤aSCore implementation of 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. ÚwinÚcygwinÚdarwincCs1tjjtƒr!dd„}n dd„}|S)NcSs dtjkS)z5True if filenames must be checked case-insensitively.s PYTHONCASEOK)Ú_osÚenviron©rrú9/opt/alt/python34/lib64/python3.4/importlib/_bootstrap.pyÚ _relax_casesz%_make_relax_case.._relax_casecSsdS)z5True if filenames must be checked case-insensitively.Frrrrrr"s)ÚsysÚplatformÚ startswithÚ_CASE_INSENSITIVE_PLATFORMS)rrrrÚ_make_relax_cases r cCst|ƒd@jddƒS)z*Convert a 32-bit integer to little-endian.lÿÿéÚlittle)ÚintÚto_bytes)ÚxrrrÚ_w_long(srcCstj|dƒS)z/Convert 4 bytes in little-endian to an integer.r)rÚ from_bytes)Ú int_bytesrrrÚ_r_long-srcGstjdd„|DƒƒS)zReplacement for os.path.join().cSs%g|]}|r|jtƒ‘qSr)ÚrstripÚpath_separators)Ú.0Úpartrrrú 4s z_path_join..)Úpath_sepÚjoin)Ú path_partsrrrÚ _path_join2srcCs†ttƒdkr4|jtƒ\}}}||fSxEt|ƒD]7}|tkrA|j|ddƒ\}}||fSqAWd|fS)z Replacement for os.path.split().éÚmaxsplitÚ)ÚlenrÚ rpartitionrÚreversedÚrsplit)ÚpathÚfrontÚ_ÚtailrrrrÚ _path_split8s  r+cCs tj|ƒS)z~Stat the path. Made a separate function to make it easier to override in experiments (e.g. cache stat results). )rÚstat)r'rrrÚ _path_statDsr-c Cs:yt|ƒ}Wntk r(dSYnX|jd@|kS)z1Test whether the path is the specified mode type.Fið)r-ÚOSErrorÚst_mode)r'ÚmodeÚ stat_inforrrÚ_path_is_mode_typeNs   r2cCs t|dƒS)zReplacement for os.path.isfile.i€)r2)r'rrrÚ _path_isfileWsr3cCs"|stjƒ}nt|dƒS)zReplacement for os.path.isdir.i@)rÚgetcwdr2)r'rrrÚ _path_isdir\sr5i¶cCsÀdj|t|ƒƒ}tj|tjtjBtjB|d@ƒ}y<tj|dƒ�}|j |ƒWdQXtj ||ƒWn;t k r»ytj |ƒWnt k r³YnX‚YnXdS)z¢Best-effort function to write data to a path atomically. Be prepared to handle a FileExistsError if concurrent writing of the temporary file is attempted.z{}.{}i¶ÚwbN) ÚformatÚidrÚopenÚO_EXCLÚO_CREATÚO_WRONLYÚ_ioÚFileIOÚwriteÚreplacer.Úunlink)r'Údatar0Úpath_tmpÚfdÚfilerrrÚ _write_atomiccs !  rFcCs_xEddddgD]1}t||ƒrt||t||ƒƒqqW|jj|jƒdS)z/Simple substitute for functools.update_wrapper.Ú __module__Ú__name__Ú __qualname__Ú__doc__N)ÚhasattrÚsetattrÚgetattrÚ__dict__Úupdate)ÚnewÚoldr@rrrÚ_wrapys rRcCsttƒ|ƒS)N)Útyper )ÚnamerrrÚ _new_module�srUc@s:eZdZdZdd„Zdd„Zdd„ZdS) Ú _ManageReloadz?Manages the possible clean-up of sys.modules for load_module().cCs ||_dS)N)Ú_name)ÚselfrTrrrÚ__init__�sz_ManageReload.__init__cCs|jtjk|_dS)N)rWr ÚmodulesÚ _is_reload)rXrrrÚ __enter__�sz_ManageReload.__enter__c GsPtdd„|DƒƒrL|j rLytj|j=WqLtk rHYqLXndS)Ncss|]}|dk VqdS)Nr)rÚargrrrú ”sz)_ManageReload.__exit__..)Úanyr[r rZrWÚKeyError)rXÚargsrrrÚ__exit__“s # z_ManageReload.__exit__N)rHrGrIrJrYr\rbrrrrrV‰s   rVc@seZdZdS)Ú_DeadlockErrorN)rHrGrIrrrrrc¢s rcc@sReZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) Ú _ModuleLockz©A recursive lock implementation which is able to detect deadlocks (e.g. thread 1 trying to take locks A then B, and thread 2 trying to take locks B then A). cCsFtjƒ|_tjƒ|_||_d|_d|_d|_dS)Né)Ú_threadÚ allocate_lockÚlockÚwakeuprTÚownerÚcountÚwaiters)rXrTrrrrY¬s    z_ModuleLock.__init__cCsXtjƒ}|j}x<tj|ƒ}|dkr7dS|j}||krdSqWdS)NFT)rfÚ get_identrjÚ _blocking_onÚget)rXÚmeÚtidrhrrrÚ has_deadlock´s     z_ModuleLock.has_deadlockcCs×tjƒ}|t|.cb)rr`rfrxrdÚ_weakrefÚref)rTrhr€r)rTrr{s    r{c CsGt|ƒ}tjƒy|jƒWntk r8Yn X|jƒdS)aRelease the global import lock, and acquires then release the module lock for a given module name. This is used to ensure a module is completely initialized, in the event it is being imported by another thread. Should only be called with the import lock taken.N)r{r|r}rsrcrt)rTrhrrrÚ_lock_unlock_module%s   rƒcOs |||ŽS)a.remove_importlib_frames in import.c will always remove sequences of importlib frames that end with a call to this function Use it instead of a normal call in places where including the importlib frames introduces unwanted noise into the traceback (e.g. when executing module code) r)ÚfraÚkwdsrrrÚ_call_with_frames_removed9sr†iî érs Ú __pycache__z.pyz.pycz.pyoNc CsÀ|dkrtjj n|}|r.t}nt}t|ƒ\}}|jdƒ\}}}tjj} | dkr…t dƒ‚ndj |r—|n||| |dgƒ} t |t | ƒS)aôGiven the path to a .py file, return the path to its .pyc/.pyo file. The .py file does not need to exist; this simply returns the path to the .pyc/.pyo file calculated as if the .py file were imported. The extension will be .pyc unless sys.flags.optimize is non-zero, then it will be .pyo. If debug_override is not None, then it must be a boolean and is used in place of sys.flags.optimize. If sys.implementation.cache_tag is None then NotImplementedError is raised. NÚ.z$sys.implementation.cache_tag is Noner"re) r ÚflagsÚoptimizeÚDEBUG_BYTECODE_SUFFIXESÚOPTIMIZED_BYTECODE_SUFFIXESr+r$ÚimplementationÚ cache_tagÚNotImplementedErrorrrÚ_PYCACHE) r'Údebug_overrideÚdebugÚsuffixesÚheadr*ÚbaseÚsepÚrestÚtagÚfilenamerrrÚcache_from_sourceµs    +r›cCsÁtjjdkr!tdƒ‚nt|ƒ\}}t|ƒ\}}|tkrltdjt|ƒƒ‚n|jdƒdkr™tdj|ƒƒ‚n|j dƒd}t ||t dƒS)ayGiven the path to a .pyc./.pyo file, return the path to its .py file. The .pyc/.pyo file does not need to exist; this simply returns the path to the .py file calculated to correspond to the .pyc/.pyo file. If path does not conform to PEP 3147 format, ValueError will be raised. If sys.implementation.cache_tag is None then NotImplementedError is raised. Nz$sys.implementation.cache_tag is Nonez%{} not bottom-level directory in {!r}r‰r‡zexpected only 2 dots in {!r}re) r rŽr�r�r+r‘Ú ValueErrorr7rkÚ partitionrÚSOURCE_SUFFIXES)r'r•Úpycache_filenameÚpycacheÚ base_filenamerrrÚsource_from_cacheÐs    r¢c Cs¤t|ƒdkrdS|jdƒ\}}}| sQ|jƒdd…dkrU|Syt|ƒ}Wn(ttfk r�|dd …}YnXt|ƒr |S|S) z¼Convert a bytecode file path to a source path (if possible). This function exists purely for backwards-compatibility for PyImport_ExecCodeModuleWithFilenames() in the C API. reNr‰ér Úpyéýÿÿÿéÿÿÿÿr¦)r#r$Úlowerr¢r�rœr3)Ú bytecode_pathr˜r)Ú extensionÚ source_pathrrrÚ_get_sourcefileçs#r«c Cs<yt|ƒj}Wntk r-d}YnX|dO}|S)z3Calculate the mode permissions for a bytecode file.i¶é€)r-r/r.)r'r0rrrÚ _calc_modeús    r­Ú verbosityr cGsQtjj|krM|jdƒs.d|}nt|j|ŒdtjƒndS)z=Print the message to stderr if -v/PYTHONVERBOSE is turned on.ú#úimport z# rEN)r¯r°)r rŠÚverboser Úprintr7Ústderr)Úmessager®rarrrÚ_verbose_messages rµcs&d‡fdd†}t|ˆƒ|S)züDecorator 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. NcsS|dkr|j}n(|j|kr@td|d|ƒ‚nˆ||||ŽS)Nzloader cannot handle %srT)rTÚ ImportError)rXrTrar~)ÚmethodrrÚ_check_name_wrappers   z(_check_name.._check_name_wrapper)rR)r·r¸r)r·rÚ _check_names r¹cs#‡fdd†}t|ˆƒ|S)z1Decorator to verify the named module is built-in.cs:|tjkr-tdj|ƒd|ƒ‚nˆ||ƒS)Nz{!r} is not a built-in modulerT)r Úbuiltin_module_namesr¶r7)rXÚfullname)ÚfxnrrÚ_requires_builtin_wrapper"s z4_requires_builtin.._requires_builtin_wrapper)rR)r¼r½r)r¼rÚ_requires_builtin s r¾cs#‡fdd†}t|ˆƒ|S)z/Decorator to verify the named module is frozen.cs:tj|ƒs-tdj|ƒd|ƒ‚nˆ||ƒS)Nz{!r} is not a frozen modulerT)r|Ú is_frozenr¶r7)rXr»)r¼rrÚ_requires_frozen_wrapper-s z2_requires_frozen.._requires_frozen_wrapper)rR)r¼rÀr)r¼rÚ_requires_frozen+s rÁcCsW|j|ƒ\}}|dkrSt|ƒrSd}tj|j|dƒtƒn|S)z›Try 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__re)Ú find_loaderr#Ú _warningsÚwarnr7Ú ImportWarning)rXr»ÚloaderÚportionsÚmsgrrrÚ_find_module_shim6s  rÉcCs]t||ƒ}t|ƒ}|tjkrOtj|}|j|ƒtj|S|jƒSdS)z€Load the specified module into sys.modules and return it. This method is deprecated. Use loader.exec_module instead. N)Úspec_from_loaderÚ _SpecMethodsr rZÚexecÚload)rXr»ÚspecÚmethodsÚmodulerrrÚ_load_module_shimGs    rÑc Csÿi}|dk r||d||dr'réé zbad magic number in {!r}: {!r}z{}z+reached EOF while reading timestamp in {!r}z0reached EOF while reading size of source in {!r}Úmtimezbytecode is stale for {!r}Úsizelÿÿ) Ú MAGIC_NUMBERr7rµr¶r#ÚEOFErrorrr`r) rBÚ source_statsrTr'Ú exc_detailsÚmagicÚ raw_timestampÚraw_sizer´Ú source_mtimeÚ source_sizerrrÚ_validate_bytecode_headerWsL             rßcCsstj|ƒ}t|tƒrNtd|ƒ|dk rJtj||ƒn|Stdj|ƒd|d|ƒ‚dS)zzz) rMrKr÷Ú ExceptionÚ__spec__ÚAttributeErrorrËrHÚ__file__r7)rÐrÆrÎrTršrrrÚ _module_repr²s.           rýc@s4eZdZdd„Zdd„Zdd„ZdS)Ú_installed_safelycCs||_|j|_dS)N)Ú_modulerúÚ_spec)rXrÐrrrrYØs z_installed_safely.__init__cCs&d|j_|jtj|jj.zimport {!r} # {!r}F) rr_r rZrTr`rµrÆr)rXrarÎrrrrbãs  z_installed_safely.__exit__N)rHrGrIrYr\rbrrrrrþÖs   rþc@s¬eZdZdZdddddddd„Zdd „Zd d „Zed d „ƒZej dd „ƒZedd„ƒZ edd„ƒZ e j dd„ƒZ dS)Ú ModuleSpecaÐThe specification for a module, used for loading. A module's spec is the source for information about the module. For data associated with the module, including source, use the spec's loader. `name` is the absolute name of the module. `loader` is the loader to use when loading the module. `parent` is the name of the package the module is in. The parent is derived from the name. `is_package` determines if the module is considered a package or not. On modules this is reflected by the `__path__` attribute. `origin` is the specific location used by the loader from which to load the module, if that information is available. When filename is set, origin will match. `has_location` indicates that a spec's "origin" reflects a location. When this is True, `__file__` attribute of the module is set. `cached` is the location of the cached bytecode file, if any. It corresponds to the `__cached__` attribute. `submodule_search_locations` is the sequence of path entries to search when importing submodules. If set, is_package should be True--and False otherwise. Packages are simply modules that (may) have submodules. If a spec has a non-None value in `submodule_search_locations`, the import system will consider modules loaded from the spec as packages. Only finders (see importlib.abc.MetaPathFinder and importlib.abc.PathEntryFinder) should modify ModuleSpec instances. ÚoriginNÚ loader_stateÚ is_packagecCsO||_||_||_||_|r0gnd|_d|_d|_dS)NF)rTrÆrrÚsubmodule_search_locationsÚ _set_fileattrÚ_cached)rXrTrÆrrrrrrrYs     zModuleSpec.__init__cCs™dj|jƒdj|jƒg}|jdk rO|jdj|jƒƒn|jdk rz|jdj|jƒƒndj|jjdj|ƒƒS)Nz name={!r}z loader={!r}z origin={!r}zsubmodule_search_locations={}z{}({})z, ) r7rTrÆrÚappendrÚ __class__rHr)rXrarrrrw"s zModuleSpec.__repr__c Cs‘|j}yk|j|jkor|j|jkor|j|jkor||jkor|j|jkor|j|jkSWntk rŒdSYnXdS)NF)rrTrÆrÚcachedÚ has_locationrû)rXÚotherÚsmslrrrÚ__eq__,s  zModuleSpec.__eq__c Csž|jdkr—|jdk r—|jr—|j}|jttƒƒrpyt|ƒ|_Wq‘tk rlYq‘Xq”|jttƒƒr”||_q”q—n|jS)N) rrrÚendswithÚtupleržr›r�ÚBYTECODE_SUFFIXES)rXršrrrr 8s  zModuleSpec.cachedcCs ||_dS)N)r)rXr rrrr FscCs.|jdkr#|jjdƒdS|jSdS)z The name of the module's parent.Nr‰re)rrTr$)rXrrrÚparentJszModuleSpec.parentcCs|jS)N)r)rXrrrr RszModuleSpec.has_locationcCst|ƒ|_dS)N)Úboolr)rXÚvaluerrrr Vs) rHrGrIrJrYrwrÚpropertyr Úsetterrr rrrrrñs # rrrcCsÁt|dƒrS|dkr+t|d|ƒS|r7gnd}t|d|d|ƒS|dkr¨t|dƒrŸy|j|ƒ}Wq¥tk r›d}Yq¥Xq¨d}nt||d|d|ƒS)z5Return a module spec based on various loader methods.Ú get_filenameNrÆrrFr)rKÚspec_from_file_locationrr¶r)rTrÆrrÚsearchrrrrÊ[s    rÊrÆrc Csn|dkrOd}t|dƒrOy|j|ƒ}WqLtk rHYqLXqOnt||d|ƒ}d|_|dkrËxOtƒD]=\}}|jt|ƒƒrƒ|||ƒ}||_PqƒqƒWdSn|t kr&t|dƒr/y|j |ƒ}Wntk r Yq#X|r#g|_ q#q/n ||_ |j gkrj|rjt |ƒd}|j j |ƒqjn|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 rrTrre)rKrr¶rrÚ_get_supported_file_loadersrrrÆÚ _POPULATErrr+r ) rTÚlocationrÆrrÎÚ loader_classr”rÚdirnamerrrrts<         rc5Cs|y |j}Wntk r!YnX|dk r2|S|j}|dkrly |j}Wqltk rhYqlXny |j}Wntk r“d}YnX|dkrà|dkr×y |j}WqÝtk rÓd}YqÝXqà|}ny |j}Wntk rd}YnXyt|jƒ}Wntk r5d}YnXt ||d|ƒ}|dkr]dnd|_ ||_ ||_ |S)NrFT) rúrûrHrörüÚ_ORIGINÚ __cached__ÚlistÚ__path__rrr r)rÐrÆrrÎrTrr rrrrÚ_spec_from_module´sH                      r$c@sŽeZdZdZdd„Zdd„Zdddd d d „Zd d „Zdd„Zdd„Z dd„Z dd„Z dd„Z dS)rËzMConvenience wrapper around spec objects to provide spec-specific methods.cCs ||_dS)N)rÎ)rXrÎrrrrYèsz_SpecMethods.__init__cCsž|j}|jdkrdn|j}|jdkrh|jdkrRdj|ƒSdj||jƒSn2|jr„dj||jƒSdj|j|jƒSdS)z&Return the repr to use for the module.Nrøz zzz)rÎrTrrÆr7r )rXrÎrTrrrr÷ës   z_SpecMethods.module_reprÚ _overrideFÚ _force_nameTc;CsK|j}|s-|s-t|ddƒdkrUy|j|_WqUtk rQYqUXn|sst|ddƒdkrÝ|j}|dkr¸|jdk r¸tjtƒ}|j|_ q¸ny ||_ WqÝtk rÙYqÝXn|sût|ddƒdkr#y|j |_ Wq#tk rYq#Xny ||_ Wntk rDYnX|sct|ddƒdkr�|jdk r�y|j|_Wqštk r–YqšXq�n|jrG|sÄt|ddƒdkrìy|j|_Wqìtk rèYqìXn|s t|ddƒdkrG|jdk rDy|j|_WqAtk r=YqAXqDqGndS)aSet the module's attributes. All missing import-related module attributes will be set. Here is how the spec attributes map onto the module: spec.name -> module.__name__ spec.loader -> module.__loader__ spec.parent -> module.__package__ spec -> module.__spec__ Optional: spec.origin -> module.__file__ (if spec.set_fileattr is true) spec.cached -> module.__cached__ (if __file__ also set) spec.submodule_search_locations -> module.__path__ (if set) rHNröÚ __package__r#rür!)rÎrMrTrHrûrÆrÚ_NamespaceLoaderÚ__new__Ú_pathrörr'rúr#r rrür r!)rXrÐr%r&rÎrÆrrrÚinit_module_attrsûsX               z_SpecMethods.init_module_attrscCse|j}t|jdƒr0|jj|ƒ}nd}|dkrTt|jƒ}n|j|ƒ|S)z™Return a new module to be loaded. The import-related module attributes are also set with the appropriate values from the spec. Ú create_moduleN)rÎrKrÆr,rUrTr+)rXrÎrÐrrrÚcreateKs   z_SpecMethods.createcCs|jjj|ƒdS)z½Do everything necessary to execute the module. The namespace of `module` is used as the target of execution. This method uses the loader's `exec_module()` method. N)rÎrÆÚ exec_module)rXrÐrrrÚ_execbsz_SpecMethods._execc Cs|jj}tjƒt|ƒ�âtjj|ƒ|k r_dj|ƒ}t |d|ƒ‚n|jj dkrµ|jj dkržt dd|jjƒ‚n|j |ddƒ|S|j |ddƒt |jj dƒsó|jj j|ƒn |j|ƒWdQXtj|S)z3Execute the spec in an existing module's namespace.zmodule {!r} not in sys.modulesrTNzmissing loaderr%Tr.)rÎrTr|Ú acquire_lockryr rZror7r¶rÆrr+rKÚ load_moduler/)rXrÐrTrÈrrrrÌls    z_SpecMethods.execcCs|j}|jj|jƒtj|j}t|ddƒdkrly|j|_Wqltk rhYqlXnt|ddƒdkr×y;|j |_ t |dƒs¾|jj dƒd|_ nWq×tk rÓYq×Xnt|ddƒdkry ||_ Wqtk rYqXn|S)Nrör'r#r‰rerú)rÎrÆr1rTr rZrMrörûrHr'rKr$rú)rXrÎrÐrrrÚ_load_backward_compatible„s*       z&_SpecMethods._load_backward_compatiblec Cs³|jjdk r4t|jjdƒs4|jƒSn|jƒ}t|ƒ�T|jjdkr�|jjdkrœtdd|jjƒ‚qœn |j |ƒWdQXt j |jjS)Nr.zmissing loaderrT) rÎrÆrKr2r-rþrr¶rTr/r rZ)rXrÐrrrÚ_load_unlocked¢s   z_SpecMethods._load_unlockedcCs1tjƒt|jjƒ�|jƒSWdQXdS)zÏReturn a new module object, loaded by the spec's loader. The module is not added to its parent. If a module is already in sys.modules, that existing module gets clobbered. N)r|r0ryrÎrTr3)rXrrrr͹s z_SpecMethods.loadN) rHrGrIrJrYr÷r+r-r/rÌr2r3rÍrrrrrËás   P    rËc CsÉ|jdƒ}|jdƒ}|sf|r6|j}qf||krTt||ƒ}qft||ƒ}n|s„t||d|ƒ}ny,||d<||d<||d<||d)r7rH)rÐrrrr÷észBuiltinImporter.module_reprNcCs:|dk rdStj|ƒr2t||ddƒSdSdS)Nrzbuilt-in)r|Ú is_builtinrÊ)Úclsr»r'ÚtargetrrrÚ find_specòs  zBuiltinImporter.find_speccCs)|j||ƒ}|dk r%|jSdS)z¯Find the built-in module. If 'path' is ever specified then the search is considered a failure. This method is deprecated. Use find_spec() instead. N)r>rÆ)r<r»r'rÎrrrÚ find_moduleûs zBuiltinImporter.find_modulec Cs;t|ƒ�ttj|ƒ}WdQX||_d|_|S)zLoad a built-in module.Nr")rVr†r|Ú init_builtinrör')r<r»rÐrrrr1s    zBuiltinImporter.load_modulecCsdS)z9Return None as built-in modules do not have code objects.Nr)r<r»rrrÚget_codeszBuiltinImporter.get_codecCsdS)z8Return None as built-in modules do not have source code.Nr)r<r»rrrÚ get_sourceszBuiltinImporter.get_sourcecCsdS)z4Return False as built-in modules are never packages.Fr)r<r»rrrrszBuiltinImporter.is_package)rHrGrIrJÚ staticmethodr÷Ú classmethodr>r?r¾r1rArBrrrrrr:às    r:c@sÁeZdZdZedd„ƒZedddd„ƒZeddd„ƒZed d „ƒZ ed d „ƒZ ee d d„ƒƒZ ee dd„ƒƒZ ee dd„ƒƒZdS)ÚFrozenImporterzŽMeta path import for frozen modules. All methods are either class or static methods to avoid the need to instantiate the class. cCsdj|jƒS)zsReturn repr for the module. The method is deprecated. The import machinery does the job itself. z)r7rH)Úmrrrr÷/szFrozenImporter.module_reprNcCs*tj|ƒr"t||ddƒSdSdS)NrÚfrozen)r|r¿rÊ)r<r»r'r=rrrr>8szFrozenImporter.find_speccCstj|ƒr|SdS)z]Find a frozen module. This method is deprecated. Use find_spec() instead. N)r|r¿)r<r»r'rrrr??szFrozenImporter.find_modulecCs_|jj}tj|ƒs9tdj|ƒd|ƒ‚nttj|ƒ}t||j ƒdS)Nz{!r} is not a frozen modulerT) rúrTr|r¿r¶r7r†Úget_frozen_objectrÌrN)rÐrTrårrrr.Hs   zFrozenImporter.exec_modulecCs t||ƒS)z_Load a frozen module. This method is deprecated. Use exec_module() instead. )rÑ)r<r»rrrr1QszFrozenImporter.load_modulecCs tj|ƒS)z-Return the code object for the frozen module.)r|rH)r<r»rrrrAZszFrozenImporter.get_codecCsdS)z6Return None as frozen modules do not have source code.Nr)r<r»rrrrB`szFrozenImporter.get_sourcecCs tj|ƒS)z.Return True if the frozen module is a package.)r|Úis_frozen_package)r<r»rrrrfszFrozenImporter.is_package)rHrGrIrJrCr÷rDr>r?r.r1rÁrArBrrrrrrE&s    rEc@syeZdZdZdZdZdZedd„ƒZedd„ƒZ ed d d d „ƒZ ed d 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}\DebugFc CsCytjtj|ƒSWn%tk r>tjtj|ƒSYnXdS)N)Ú_winregÚOpenKeyÚHKEY_CURRENT_USERr.ÚHKEY_LOCAL_MACHINE)r<ÚkeyrrrÚ_open_registryys z$WindowsRegistryFinder._open_registrycCsŽ|jr|j}n |j}|jd|dtjdd…ƒ}y.|j|ƒ�}tj|dƒ}WdQXWnt k r‰dSYnX|S)Nr»Ú sys_versionr£r") Ú DEBUG_BUILDÚREGISTRY_KEY_DEBUGÚ REGISTRY_KEYr7r ÚversionrPrKÚ QueryValuer.)r<r»Ú registry_keyrOÚhkeyÚfilepathrrrÚ_search_registry€s     z&WindowsRegistryFinder._search_registryNcCs›|j|ƒ}|dkrdSyt|ƒWntk rEdSYnXxNtƒD]C\}}|jt|ƒƒrPt||||ƒd|ƒ}|SqPWdS)Nr)rZr-r.rrrrÊ)r<r»r'r=rYrÆr”rÎrrrr>�s    zWindowsRegistryFinder.find_speccCs-|j||ƒ}|dk r%|jSdSdS)zlFind module named in the registry. This method is deprecated. Use exec_module() instead. N)r>rÆ)r<r»r'rÎrrrr?žs z!WindowsRegistryFinder.find_module) rHrGrIrJrTrSrRrDrPrZr>r?rrrrrJms rJc@s4eZdZdZdd„Zdd„ZeZdS)Ú _LoaderBasicszSBase class of common code needed by both SourceLoader and SourcelessFileLoader.cCsXt|j|ƒƒd}|jddƒd}|jdƒd}|dkoW|dkS)z�Concrete implementation of InspectLoader.is_package by checking if the path returned by get_filename has a filename of '__init__.py'.r r‰rer‡rY)r+rr&r$)rXr»ršÚ filename_baseÚ tail_namerrrr±sz_LoaderBasics.is_packagecCsP|j|jƒ}|dkr9tdj|jƒƒ‚ntt||jƒdS)zExecute the module.Nz4cannot load module {!r} when get_code() returns None)rArHr¶r7r†rÌrN)rXrÐrårrrr.¹s   z_LoaderBasics.exec_moduleN)rHrGrIrJrr.rÑr1rrrrr[¬s   r[c@sjeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd dd d„Zdd„Z dS)Ú SourceLoadercCs t‚dS)z²Optional method that returns the modification time (an int) for the specified path, where path is a str. Raises IOError when the path cannot be handled. N)ÚIOError)rXr'rrrÚ path_mtimeÆszSourceLoader.path_mtimecCsi|j|ƒd6S)aªOptional method returning a metadata dict for the specified path to by the path (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 IOError when the path cannot be handled. rÔ)r`)rXr'rrrÚ path_statsÎs zSourceLoader.path_statscCs|j||ƒS)zäOptional 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)rXrªÚ cache_pathrBrrrÚ_cache_bytecodeÛszSourceLoader._cache_bytecodecCsdS)z–Optional method which writes data (bytes) to a file path (a str). Implementing this method allows for the writing of bytecode files. Nr)rXr'rBrrrrbåszSourceLoader.set_datacCsi|j|ƒ}y|j|ƒ}Wn:tk r^}ztdd|ƒ|‚WYdd}~XnXt|ƒS)z4Concrete implementation of InspectLoader.get_source.z'source not available through get_data()rTN)rÚget_datar.r¶rõ)rXr»r'rñÚexcrrrrBìs zSourceLoader.get_sourceÚ _optimizer c Cstt||dddd|ƒS)z‚Return the code object compiled from source. The 'data' argument can be any object type that compile() supports. rÌÚ dont_inheritTr‹)r†Úcompile)rXrBr'rgrrrÚsource_to_codeöszSourceLoader.source_to_codec +Cs±|j|ƒ}d}yt|ƒ}Wntk r?d}YnÊXy|j|ƒ}Wntk rgYn¢Xt|dƒ}y|j|ƒ}Wntk rŸYnjXy"t|d|d|d|ƒ}Wnt t fk rÜYn-Xt d||ƒt |d|d|d|ƒS|j|ƒ}|j ||ƒ} t d |ƒtj r­|dk r­|dk r­t| |t|ƒƒ}y$|j|||ƒt d |ƒWq­tk r©Yq­Xn| S) z¾Concrete implementation of InspectLoader.get_code. Reading of bytecode requires path_stats to be implemented. To write bytecode, set_data must also be implemented. NrÔrØrTr'z {} matches {}r¨rªzcode object from {}z wrote {!r})rr›r�rar_rrer.rßr¶r×rµrærjr Údont_write_bytecoderêr#rd) rXr»rªrÝr¨ÚstrBÚ bytes_datarñÚ code_objectrrrrAþsN            zSourceLoader.get_codeNr¦) rHrGrIr`rardrbrBrjrArrrrr^Äs    r^cspeZdZdZdd„Zdd„Zdd„Ze‡fdd †ƒZed d „ƒZ d d „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.N)rTr')rXr»r'rrrrY7s zFileLoader.__init__cCs"|j|jko!|j|jkS)N)r rN)rXr rrrr=szFileLoader.__eq__cCst|jƒt|jƒAS)N)ÚhashrTr')rXrrrÚ__hash__AszFileLoader.__hash__cstt|ƒj|ƒS)zdLoad a module from a file. This method is deprecated. Use exec_module() instead. )Úsuperror1)rXr»)r rrr1Ds zFileLoader.load_modulecCs|jS)z:Return the path to the source file as found by the finder.)r')rXr»rrrrPszFileLoader.get_filenamecCs)tj|dƒ�}|jƒSWdQXdS)z'Return the data from path as raw bytes.ÚrN)r=r>Úread)rXr'rErrrreUszFileLoader.get_data) rHrGrIrJrYrrqr¹r1rrerr)r rro2s     roc@s@eZdZdZdd„Zdd„Zdddd „Zd S) r5z>Concrete implementation of SourceLoader using the file system.cCs$t|ƒ}i|jd6|jd6S)z!Return the metadata for the path.rÔrÕ)r-Úst_mtimeÚst_size)rXr'rlrrrra_s zSourceFileLoader.path_statscCs"t|ƒ}|j||d|ƒS)NÚ_mode)r­rb)rXrªr¨rBr0rrrrdds z SourceFileLoader._cache_bytecoderwi¶c Cs5t|ƒ\}}g}x6|rPt|ƒ rPt|ƒ\}}|j|ƒqWx„t|ƒD]v}t||ƒ}ytj|ƒWq^tk r›w^Yq^tk rÓ}zt d||ƒdSWYdd}~Xq^Xq^Wy!t |||ƒt d|ƒWn5tk r0}zt d||ƒWYdd}~XnXdS)zWrite bytes data to a file.zcould not create {!r}: {!r}Nz created {!r}) r+r5r r%rrÚmkdirÚFileExistsErrorr.rµrF) rXr'rBrwrršrrrfrrrrbis& zSourceFileLoader.set_dataN)rHrGrIrJrardrbrrrrr5[s   r5c@s.eZdZdZdd„Zdd„ZdS)r4z-Loader which handles sourceless file imports.cCsL|j|ƒ}|j|ƒ}t|d|d|ƒ}t|d|d|ƒS)NrTr'r¨)rrerßræ)rXr»r'rBrmrrrrAŠszSourcelessFileLoader.get_codecCsdS)z'Return None as there is no source code.Nr)rXr»rrrrB�szSourcelessFileLoader.get_sourceN)rHrGrIrJrArBrrrrr4†s  r4c@s‚eZdZdZdd„Zdd„Zdd„Zedd „ƒZd d „Z d d „Z dd„Z edd„ƒZ dS)ÚExtensionFileLoaderz]Loader for extension modules. The constructor is designed to work with FileFinder. cCs||_||_dS)N)rTr')rXrTr'rrrrY¡s zExtensionFileLoader.__init__cCs"|j|jko!|j|jkS)N)r rN)rXr rrrr¥szExtensionFileLoader.__eq__cCst|jƒt|jƒAS)N)rprTr')rXrrrrq©szExtensionFileLoader.__hash__c Cs·t|ƒ�ttj||jƒ}WdQXtd|jƒ|j|ƒ}|r|t|dƒ r|t|jƒdg|_ n||_ |j |_ |s³|j j dƒd|_ n|S)zLoad an extension module.Nz!extension module loaded from {!r}r#rer‰)rVr†r|Ú load_dynamicr'rµrrKr+r#rörHr'r$)rXr»rÐrrrrr1¬s    zExtensionFileLoader.load_modulecs0t|jƒd‰t‡fdd†tDƒƒS)z1Return True if the extension module is a package.r c3s|]}ˆd|kVqdS)rYNr)rÚsuffix)Ú file_namerrr^Ász1ExtensionFileLoader.is_package..)r+r'r_ÚEXTENSION_SUFFIXES)rXr»r)r}rr¾szExtensionFileLoader.is_packagecCsdS)z?Return None as an extension module cannot create a code object.Nr)rXr»rrrrAÄszExtensionFileLoader.get_codecCsdS)z5Return None as extension modules have no source code.Nr)rXr»rrrrBÈszExtensionFileLoader.get_sourcecCs|jS)z:Return the path to the source file as found by the finder.)r')rXr»rrrrÌsz ExtensionFileLoader.get_filenameN) rHrGrIrJrYrrqr¹r1rrArBrrrrrrz™s       rzc@s‚eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dS)Ú_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.cCs4||_||_t|jƒƒ|_||_dS)N)rWr*rÚ_get_parent_pathÚ_last_parent_pathÚ _path_finder)rXrTr'Ú path_finderrrrrYÙs  z_NamespacePath.__init__cCs5|jjdƒ\}}}|dkr+dS|dfS)z>Returns a tuple of (parent-module-name, parent-path-attr-name)r‰r"r r'r#)zsyszpath)rWr$)rXrÚdotrprrrÚ_find_parent_path_namesßs z&_NamespacePath._find_parent_path_namescCs&|jƒ\}}ttj||ƒS)N)r…rMr rZ)rXÚparent_module_nameÚpath_attr_namerrrr€ész_NamespacePath._get_parent_pathcCst|jƒƒ}||jkrx|j|j|ƒ}|dk rl|jdkrl|jrl|j|_qln||_n|jS)N)rr€r�r‚rWrÆrr*)rXÚ parent_pathrÎrrrÚ _recalculateís  z_NamespacePath._recalculatecCst|jƒƒS)N)Úiterr‰)rXrrrÚ__iter__úsz_NamespacePath.__iter__cCst|jƒƒS)N)r#r‰)rXrrrÚ__len__ýsz_NamespacePath.__len__cCsdj|jƒS)Nz_NamespacePath({!r}))r7r*)rXrrrrwsz_NamespacePath.__repr__cCs||jƒkS)N)r‰)rXÚitemrrrÚ __contains__sz_NamespacePath.__contains__cCs|jj|ƒdS)N)r*r )rXr�rrrr sz_NamespacePath.appendN) rHrGrIrJrYr…r€r‰r‹rŒrwrŽr rrrrrÒs       rc@sjeZdZdd„Zedd„ƒZdd„Zdd„Zd d „Zd d „Z d d„Z dS)r(cCst|||ƒ|_dS)N)rr*)rXrTr'rƒrrrrY sz_NamespaceLoader.__init__cCsdj|jƒS)zsReturn repr for the module. The method is deprecated. The import machinery does the job itself. z)r7rH)r<rÐrrrr÷sz_NamespaceLoader.module_reprcCsdS)NTr)rXr»rrrrsz_NamespaceLoader.is_packagecCsdS)Nr"r)rXr»rrrrBsz_NamespaceLoader.get_sourcecCstdddddƒS)Nr"zrÌrhT)ri)rXr»rrrrAsz_NamespaceLoader.get_codecCsdS)Nr)rXrÐrrrr.!sz_NamespaceLoader.exec_modulecCstd|jƒt||ƒS)zbLoad a namespace module. This method is deprecated. Use exec_module() instead. z&namespace module loaded with path {!r})rµr*rÑ)rXr»rrrr1$sz_NamespaceLoader.load_moduleN) rHrGrIrYrDr÷rrBrAr.r1rrrrr( s      r(c@s eZdZdZedd„ƒZedd„ƒZedd„ƒZedd „ƒZed d d „ƒZ ed d d d„ƒZ ed dd„ƒZ d S)Ú PathFinderz>Meta path finder for sys.path and package __path__ attributes.cCs:x3tjjƒD]"}t|dƒr|jƒqqWdS)z}Call the invalidate_caches() method on all path entry finders stored in sys.path_importer_caches (where implemented).Úinvalidate_cachesN)r Úpath_importer_cacheÚvaluesrKr�)r<Úfinderrrrr�5szPathFinder.invalidate_cachesc Cs^tjstjdtƒnx;tjD],}y||ƒSWq&tk rQw&Yq&Xq&WdSdS)zqSearch sequence of hooks for a finder for 'path'. If 'hooks' is false then use sys.path_hooks. zsys.path_hooks is emptyN)r Ú path_hooksrÃrÄrÅr¶)r<r'ÚhookrrrÚ _path_hooks=s   zPathFinder._path_hooksc Csa|dkrtjƒ}nytj|}Wn.tk r\|j|ƒ}|tj|zspec missing loader) râÚstrÚbytesr—rKr>r˜rÆrr¶rèr) r<r»r'r=Únamespace_pathÚentryr“rÎrÇrrrÚ _get_specns(      zPathFinder._get_speccCs�|dkrtj}n|j|||ƒ}|dkr=dS|jdkr‡|j}|r€d|_t|||jƒ|_|SdSn|SdS)zbfind the module on sys.path or 'path' based on sys.path_hooks and sys.path_importer_cache.NÚ namespace)r r'r�rÆrrr)r<r»r'r=rÎr›rrrr>Žs     zPathFinder.find_speccCs)|j||ƒ}|dkr"dS|jS)zªfind 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. N)r>rÆ)r<r»r'rÎrrrr?¤s zPathFinder.find_module) rHrGrIrJrDr�r–r—r˜r�r>r?rrrrr�1s r�c@s…eZdZdZdd„Zdd„ZeZdd„Zdd „Z d d d „Z d d„Z e dd„ƒZ dd„Zd S)Ú FileFinderz¬File-based finder. Interactions with the file system are cached for performance, being refreshed when the directory the finder is handling has been modified. cszg}x4|D],\‰}|j‡fdd†|Dƒƒq W||_|pOd|_d|_tƒ|_tƒ|_dS)zšInitialize with the path to search on and a variable number of 2-tuples containing the loader and the file suffixes the loader recognizes.c3s|]}|ˆfVqdS)Nr)rr|)rÆrrr^Ász&FileFinder.__init__..r‰r Nr¦)rèÚ_loadersr'Ú _path_mtimeÚsetÚ _path_cacheÚ_relaxed_path_cache)rXr'Úloader_detailsÚloadersr”r)rÆrrY»s$   zFileFinder.__init__cCs d|_dS)zInvalidate the directory mtime.r Nr¦)r¡)rXrrrr�ÉszFileFinder.invalidate_cachescCs;|j|ƒ}|dkr%dgfS|j|jp7gfS)zÅTry 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)r>rÆr)rXr»rÎrrrrÂÏs  zFileFinder.find_loadercCs(|||ƒ}t||d|d|ƒS)NrÆr)r)rXrr»r'rr=rÆrrrr�ÛszFileFinder._get_specNcCsðd}|jdƒd}y"t|jp1tjƒƒj}Wntk rUd }YnX||jkr{|jƒ||_nt ƒrœ|j }|j ƒ}n|j }|}||kr3t |j|ƒ}xg|jD]M\} } d| } t || ƒ} t| ƒrÓ|j| || |g|ƒSqÓWt|ƒ}nx~|jD]s\} } t |j|| ƒ} tdj| ƒddƒ|| |kr=t| ƒr°|j| || d|ƒSq=q=W|rìtd j|ƒƒt|dƒ} |g| _| SdS) z}Try to find a loader for the specified module, or the namespace package portions. Returns (loader, list-of-portions).Fr‰r‡r rYz trying {}r®Nzpossible namespace for {}r¦)r$r-r'rr4rur.r¡Ú _fill_cacherr¤r§r£rr r3r�r5rµr7rr)rXr»r=Ú is_namespaceÚ tail_modulerÔÚcacheÚ cache_moduleÚ base_pathr|rÚ init_filenameÚ full_pathrÎrrrr>àsD"              zFileFinder.find_specc Cs|j}ytj|p!tjƒƒ}Wn!tttfk rKg}YnXtjj dƒspt |ƒ|_ not ƒ}xZ|D]R}|j dƒ\}}}|r¿dj ||jƒƒ}n|}|j|ƒq€W||_ tjj tƒr dd„|Dƒ|_ndS)zDFill the cache of potential modules and packages for this directory.rr‰z{}.{}cSsh|]}|jƒ’qSr)r§)rÚfnrrrú *s z)FileFinder._fill_cache..N)r'rÚlistdirr4ÚFileNotFoundErrorÚPermissionErrorÚNotADirectoryErrorr r r r¢r£r�r7r§Úaddr r¤) rXr'ÚcontentsÚlower_suffix_contentsr�rTr„r|Únew_namerrrr§ s"     zFileFinder._fill_cachecs‡‡fdd†}|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!tdd|ƒ‚nˆ|ˆŒS)z-Path hook for importlib.machinery.FileFinder.zonly directories are supportedr')r5r¶)r')r<r¥rrÚpath_hook_for_FileFinder6s z6FileFinder.path_hook..path_hook_for_FileFinderr)r<r¥r¹r)r<r¥rÚ path_hook,s zFileFinder.path_hookcCsdj|jƒS)NzFileFinder({!r}))r7r')rXrrrrw>szFileFinder.__repr__)rHrGrIrJrYr�rÉr?rÂr�r>r§rDrºrwrrrrrŸ²s    - rŸc@s.eZdZdZdd„Zdd„ZdS)Ú_ImportLockContextz$Context manager for the import lock.cCstjƒdS)zAcquire the import lock.N)r|r0)rXrrrr\Hsz_ImportLockContext.__enter__cCstjƒdS)zrûrÃrú) rTr'r=Ú is_reloadr“r>rÎrÐrúrrrÚ _find_speccs0             rÆcCsÂt|tƒs-tdjt|ƒƒƒ‚n|dkrHtdƒ‚n|rœt|tƒsltdƒ‚qœ|tjkrœd}t|j|ƒƒ‚qœn| r¾|dkr¾tdƒ‚ndS)zVerify arguments are "sane".zmodule name must be str, not {}rezlevel must be >= 0z__package__ not set to a stringz=Parent module {!r} not loaded, cannot perform relative importzEmpty module nameN) râr™Ú TypeErrorr7rSrœr rZÚ SystemError)rTr¿rÀrÈrrrÚ _sanity_check‹s rÉzNo module named z{!r}c Cs4d}|jdƒd}|r²|tjkr>t||ƒn|tjkrXtj|Stj|}y |j}Wq²tk r®tdj||ƒ}t|d|ƒ‚Yq²Xnt ||ƒ}|dkrëttj|ƒd|ƒ‚nt |ƒj ƒ}|r0tj|}t ||jdƒd|ƒn|S)Nr‰rez; {!r} is not a packagerTr‡) r$r rZr†r#rûÚ_ERR_MSGr7r¶rÆrËr3rL)rTÚimport_r'rÚ parent_modulerÈrÎrÐrrrÚ_find_and_load_unlockedŸs*       rÍc Cs$t|ƒ�t||ƒSWdQXdS)z6Find and load the module, and release the import lock.N)ryrÍ)rTrËrrrÚ_find_and_loadºs rÎcCs¬t|||ƒ|dkr1t|||ƒ}ntjƒ|tjkrWt|tƒStj|}|dkržtjƒdj |ƒ}t |d|ƒ‚nt |ƒ|S)a2Import and return the module based on its name, the package the call is being made from, and the level adjustment. This function represents the greatest common denominator of functionality between import_module and __import__. This includes setting __package__ if the loader did not. reNz(import of {} halted; None in sys.modulesrT) rÉrÂr|r0r rZrÎÚ _gcd_importr}r7r¶rƒ)rTr¿rÀrÐr´rrrrÏÀs         rÏcCst|dƒrýd|krYt|ƒ}|jdƒt|dƒrY|j|jƒqYnx¡|D]–}t||ƒs`dj|j|ƒ}yt||ƒWqötk rò}z5t |ƒj t ƒrÝ|j |krÝw`qÝn‚WYdd}~XqöXq`q`Wn|S)zîFigure out what __import__ should return. The import_ parameter is a callable which takes the name of module to import. It is required to decouple the function from assuming importlib's import implementation is desired. r#Ú*Ú__all__z{}.{}N) rKr"ÚremoverèrÑr7rHr†r¶r™r Ú_ERR_MSG_PREFIXrT)rÐÚfromlistrËrÚ from_namerfrrrÚ_handle_fromlistØs"       rÖcCsN|jdƒ}|dkrJ|d}d|krJ|jdƒd}qJn|S)z§Calculate what __package__ should be. __package__ is not guaranteed to be defined or could be set to None to represent that its proper value is unknown. r'NrHr#r‰re)ror$)Úglobalsr¿rrrÚ_calc___package__øs    rØcCs7ttjƒf}ttf}ttf}|||gS)z_Returns a list of file-based module loaders. Each item is a tuple (loader, suffixes). )rzr|Úextension_suffixesr5ržr4r)Ú extensionsÚsourceÚbytecoderrrr s  rc Csã|dkrt|ƒ}n6|dk r-|ni}t|ƒ}t|||ƒ}|sÏ|dkrzt|jdƒdƒS|s„|St|ƒt|jdƒdƒ}tj|jdt|jƒ|…Snt||tƒSdS)aÖImport a module. The 'globals' argument is used to infer where the import is occuring from to handle relative imports. The 'locals' argument is ignored. The 'fromlist' argument specifies what should exist as attributes on the module being imported (e.g. ``from module import ``). The 'level' argument represents the package location to import from in a relative import (e.g. ``from ..pkg import mod`` would have a 'level' of 2). reNr‰)rÏrØr�r#r rZrHrÖ) rTr×ÚlocalsrÔrÀrÐÚglobals_r¿Úcut_offrrrÚ __import__ s   #(ràcCsDtj|ƒ}|dkr.td|ƒ‚nt|ƒ}|jƒS)Nzno built-in module named )r:r>r¶rËr3)rTrÎrÏrrrÚ_builtin_from_name5 s   rác Csè|a|atjjr!tantattƒ}xŠtjj ƒD]y\}}t ||ƒrC|tj krvt }ntj |ƒrCt}nqCt||ƒ}t|ƒ}|j|ƒqCqCWtjt}xIdD]A} | tjkrøt| ƒ} n tj| } t|| | ƒqÔWddgfdddgff} x’| D]~\} } td d „| Dƒƒslt‚| d }| tjkr–tj| }PqAyt| ƒ}PWqAtk r¾wAYqAXqAWtd ƒ‚t|d |ƒt|d|ƒt|ddj| ƒƒytdƒ}Wntk r2d}YnXt|d|ƒtdƒ}t|d|ƒ| dkrŠtdƒ}t|d|ƒnt|dtƒƒtjtjƒƒ| dkrätjdƒdtkrädt_ qändS)zúSetup importlib by importing needed built-in modules and injecting them into the global namespace. As sys is needed for sys.modules access and _imp is needed to load built-in modules, those two modules must be explicitly passed in. r=rÃÚbuiltinsràÚposixú/Úntú\css!|]}t|ƒdkVqdS)r N)r#)rr—rrrr^i sz_setup..rezimportlib requires posix or ntrrrr"rfNr�ÚwinregrKrz.pywz_d.pydT)z_ioz _warningszbuiltinszmarshal)!r|r rŠr‹r�rrŒrSrZÚitemsrârºr:r¿rEr$rËr+rHrárLÚallrvr¶rr r~rèrÙržr rJrR)Ú sys_moduleÚ _imp_moduleÚ module_typerTrÐrÆrÎrÏÚ self_moduleÚ builtin_nameÚbuiltin_moduleÚ os_detailsÚ builtin_osrrÚ os_moduleÚ thread_moduleÚweakref_moduleÚ winreg_modulerrrÚ_setup= sl          !              röcCsˆt||ƒtƒ}tjjtj|Œgƒtjjt ƒtjjt ƒt j dkrttjjt ƒntjjtƒdS)z2Install importlib as the implementation of import.råN)rörr r”rèrŸrºrÄr r:rErrHrJr�)rêrëÚsupported_loadersrrrÚ_install” s  rø)zwinzcygwinzdarwin)\rJr r rrrr+r-r2r3r5rFrRrUrSÚ__code__rãrVrrnrurcrdrxryr{rƒr†rrÖrrÚ_RAW_MAGIC_NUMBERr‘ržrŒr�r›r¢r«r­rµr¹r¾rÁrÉrÑrßrærêrõrýrþrrÊÚobjectrrr$rËr9r:rErJr[r^ror5r4r~rzrr(r�rŸr»rÂrÃrÆrÉrÓrÊrÍrÎrÏrÖrØrràrárörørrrrÚsª       D   r         7   $j  ?-æFG?n)+99&�’ (      #  W