Yf) @sdZddlmZmZmZmZmZmZmZm Z m Z yddlm Z Wne k rtdZ YnXddl mZmZmZmZddlmZddlmZddlmZddlZddlZddlZddlZddlZddlZejd ed d dZd Zd Z d Z!dZ"dZ#dZ$dZ%dZ&dZ'ddZ(ddZ)ddZ*dddZ+ddZ,ddZ-Gd d!d!Z.Gd"d#d#Z/Gd$d%d%e/ej0Z1dd&d'Z2Gd(d)d)e/eZ3dd*d+Z4d,d-Z5d.d/Z6dd0d1Z7d2d3Z8d4d5Z9e r|dd6d7Z:ndZ:dS)8zThis module provides the components needed to build your own __import__ function. Undocumented functions are obsolete. In most cases it is preferred you consider using the importlib module's functionality over this module. ) lock_held acquire_lock release_lockget_frozen_objectis_frozen_package init_frozen is_builtin is_frozen_fix_co_filename)create_dynamicN)_ERR_MSG_exec_load_builtin_from_name)SourcelessFileLoader) machinery)utilzhthe imp module is deprecated in favour of importlib; see the module's documentation for alternative uses stacklevel cCs tj|S)z_**DEPRECATED** Create a new module. The module is not entered into sys.modules. )types ModuleType)namer (/opt/alt/python35/lib64/python3.5/imp.py new_module0sr"cCstjS)z@**DEPRECATED** Return the magic number for .pyc files. )r MAGIC_NUMBERr r r r! get_magic;sr$cCs tjjS)z$Return the magic tag for .pyc files.)sysimplementation cache_tagr r r r!get_tagCsr(c Cs5tj"tjdtj||SWdQRXdS)a**DEPRECATED** Given 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. 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. ignoreN)warningscatch_warnings simplefilterrcache_from_source)pathdebug_overrider r r!r-Hs  r-cCs tj|S)a~**DEPRECATED** Given 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 format, ValueError will be raised. If sys.implementation.cache_tag is None then NotImplementedError is raised. )rsource_from_cache)r.r r r!r0[s r0cCsNddtjD}ddtjD}ddtjD}|||S)z**DEPRECATED**cSsg|]}|dtfqS)rb) C_EXTENSION).0sr r r! ks z get_suffixes..cSsg|]}|dtfqS)r) PY_SOURCE)r3r4r r r!r5ls cSsg|]}|dtfqS)r1) PY_COMPILED)r3r4r r r!r5ms )rEXTENSION_SUFFIXESSOURCE_SUFFIXESBYTECODE_SUFFIXES) extensionssourcebytecoder r r! get_suffixesisr?c@s.eZdZdZddZddZdS) NullImporterz-**DEPRECATED** Null import object. cCsI|dkr!tdddn$tjj|rEtdd|dS)Nzempty pathnamer.zexisting directory) ImportErrorosr.isdir)selfr.r r r!__init__zs zNullImporter.__init__cCsdS)zAlways returns None.Nr )rEfullnamer r r! find_moduleszNullImporter.find_moduleN)__name__ __module__ __qualname____doc__rFrHr r r r!r@rs  r@cs=eZdZdZdfddZfddZS)_HackedGetDatazMCompatibility support for 'file' arguments of various load_*() functions.Ncs tj||||_dS)N)superrFfile)rErGr.rO) __class__r r!rFsz_HackedGetData.__init__c sx|jrd||jkrd|jjs0|j}nt|jd|_}||jSWdQRXntj|SdS)z;Gross hack to contort loader to deal w/ load_*()'s bad API.r6N)rOr.closedopenreadrNget_data)rEr.rO)rPr r!rTs  z_HackedGetData.get_data)rIrJrKrLrFrTr r )rPr!rMs rMc@seZdZdZdS)_LoadSourceCompatibilityz5Compatibility support for implementing load_source().N)rIrJrKrLr r r r!rUs rUcCst|||}tj||d|}|tjkrRt|tj|}n t|}tj|||_ |j |j _ |S)Nloader) rUrspec_from_file_locationr%modulesr rrSourceFileLoader __loader____spec__rV)rpathnamerOrVspecmoduler r r! load_sources r_c@seZdZdZdS)_LoadCompiledCompatibilityz7Compatibility support for implementing load_compiled().N)rIrJrKrLr r r r!r`s r`cCst|||}tj||d|}|tjkrRt|tj|}n t|}t|||_|j|j _ |S)z**DEPRECATED**rV) r`rrWr%rXr rrrZr[rV)rr\rOrVr]r^r r r! load_compileds racCstjj|rtjddtjdd}xU|D]8}tjj|d|}tjj|r=|}Pq=Wtdj |t j ||dg}|t j krt|t j |St|SdS)z**DEPRECATED**NrFz{!r} is not a packagesubmodule_search_locations)rCr.rDrr:r;joinexists ValueErrorformatrrWr%rXr r)rr.r< extensionZ init_pathr]r r r! load_packages  rhc Cs|\}}}|rI|jd  s1d|krItdj|n@|dkr|tthkrdj|}t|n|tkrt|||S|tkrt|||S|tkr tdk r |dkr t |d}t|||SWdQRXqt|||Sni|t kr9t ||S|t krOt |S|tkret|Sdj||}t|d |dS) z**DEPRECATED** Load a module, given information returned by find_module(). The module name must include the full package name, if any. r6U+zinvalid file open mode {!r}Nz.file object required for import (type code {})r1z*Don't know how to import {} (type code {})r)r6ri) startswithrerfr7r8r_rar2 load_dynamicrR PKG_DIRECTORYrh C_BUILTIN init_builtin PY_FROZENrrB) rrOfilenameZdetailssuffixmodetype_msgZ opened_filer r r! load_modules."         rvc Cs!t|ts-tdjt|n6t|tdtfsctdjt||dkrt|rddddtffSt |rddddt ffSt j }x|D]}t j j||}xbdtjdgD]M}d|}t j j||}t j j|rd|ddtffSqWxOtD]A\}}}||} t j j|| }t j j|rMPqMWqPqWttj|d|d} d |krt|d } tj| jd} WdQRXt||d | } | ||||ffS) a,**DEPRECATED** Search for a module. If path is omitted or None, search for a built-in, frozen or special module and continue search in sys.path. The module name cannot contain '.'; to search for a submodule of a package, pass the submodule name and the package's __path__. z'name' must be a str, not {}Nz%'path' must be None or a list, not {}rAz.pyrrFrbr1encoding) isinstancestr TypeErrorrftypelist RuntimeErrorrrnr rpr%r.rCrcrr;isfilermr?rBr rRtokenizedetect_encodingreadline) rr.entryZpackage_directoryrrZpackage_file_nameZ file_pathrsrt file_namerxrOr r r!rHs@          rHcCs tj|S)zw**DEPRECATED** Reload the module and return it. The module must have been successfully imported before. ) importlibreload)r^r r r!r3src Cs+yt|SWntk r&dSYnXdS)zl**DEPRECATED** Load and return a built-in module by name, or None is such module doesn't exist N)rrB)rr r r!ro>s rocCsLddl}|jj||}|jjd|d|d|}t|S)z:**DEPRECATED** Load an extension module. rNrrVorigin)importlib.machineryrExtensionFileLoader ModuleSpecr)rr.rOrrVr]r r r!rlKs   rl);rL_imprrrrrrrr r r rBZimportlib._bootstrapr r rrZimportlib._bootstrap_externalrrrrrCr%rrr*warnPendingDeprecationWarningZ SEARCH_ERRORr7r8r2Z PY_RESOURCErmrnrpZPY_CODERESOURCEZIMP_HOOKr"r$r(r-r0r?r@rMrYrUr_r`rarhrvrHrrorlr r r r!s^@  "              #4