[' @sFdZddlmZmZmZmZmZmZmZm Z m Z m Z yddlm Z Wne k rzdZ YnXddlmZmZmZddlmZddlmZddlZddlZddlZddlZddlZddlZejdedZd Zd Zd Zd Z d Z!dZ"dZ#dZ$dZ%ddZ&ddZ'ddZ(dddZ)ddZ*ddZ+GdddZ,Gd d!d!Z-Gd"d#d#e-ej.Z/dd$d%Z0Gd&d'd'e-eZ1dd(d)Z2d*d+Z3d,d-Z4dd.d/Z5d0d1Z6dS)2zThis 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_builtin init_frozen is_builtin is_frozen_fix_co_filename) load_dynamicN)SourcelessFileLoader_ERR_MSG _SpecMethods) machinery)utilzhthe imp module is deprecated in favour of importlib; see the module's documentation for alternative uses cCs tj|S)z_**DEPRECATED** Create a new module. The module is not entered into sys.modules. )types ModuleType)namer/usr/lib/python3.4/imp.py new_module/sr cCstjS)zH**DEPRECATED** Return the magic number for .pyc or .pyo files. )r MAGIC_NUMBERrrrr get_magic:sr"cCs tjjS)z,Return the magic tag for .pyc or .pyo files.)sysimplementation cache_tagrrrrget_tagBsr&cCstj||S)a**DEPRECATED** 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. )rcache_from_source)pathdebug_overriderrrr'Gsr'cCs tj|S)a**DEPRECATED** Given 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. )rsource_from_cache)r(rrrr*Ys r*cCsNddtjD}ddtjD}ddtjD}|||S)z**DEPRECATED**cSsg|]}|dtfqS)rb) C_EXTENSION).0srrr is z get_suffixes..cSsg|]}|dtfqS)r) PY_SOURCE)r-r.rrrr/js cSsg|]}|dtfqS)r+) PY_COMPILED)r-r.rrrr/ks )rEXTENSION_SUFFIXESSOURCE_SUFFIXESBYTECODE_SUFFIXES) extensionssourcebytecoderrr get_suffixesgsr9c@s.eZdZdZddZddZdS) NullImporterz-**DEPRECATED** Null import object. cCsL|dkr!tdddn'tjj|rHtdd|ndS)Nzempty pathnamer(zexisting directory) ImportErrorosr(isdir)selfr(rrr__init__xs zNullImporter.__init__cCsdS)zAlways returns None.Nr)r?fullnamerrr find_module~szNullImporter.find_moduleN)__name__ __module__ __qualname____doc__r@rBrrrrr:ps  r:cs=eZdZdZdfddZfddZS)_HackedGetDatazMCompatibiilty support for 'file' arguments of various load_*() functions.Ncs tj||||_dS)N)superr@file)r?rAr(rI) __class__rrr@sz_HackedGetData.__init__csw|jrc||jkrc|jjs0|j}nt|jd|_}||jSWdQXntj|SdS)z;Gross hack to contort loader to deal w/ load_*()'s bad API.r0N)rIr(closedopenreadrHget_data)r?r(rI)rJrrrNs  z_HackedGetData.get_data)rCrDrErFr@rNrr)rJrrGs rGc@seZdZdZdS)_LoadSourceCompatibilityz5Compatibility support for implementing load_source().N)rCrDrErFrrrrrOs rOcCst|||}tj||d|}t|}|tjkr^|jtj|}n |j}tj |||_ |j |j _ |S)Nloader) rOrspec_from_file_locationrr#modulesexecloadrSourceFileLoader __loader____spec__rP)rpathnamerIrPspecmethodsmodulerrr load_sources  r\c@seZdZdZdS)_LoadCompiledCompatibilityz7Compatibility support for implementing load_compiled().N)rCrDrErFrrrrr]s r]cCst|||}tj||d|}t|}|tjkr^|jtj|}n |j}t|||_ |j |j _ |S)z**DEPRECATED**rP) r]rrQrr#rRrSrTr rVrWrP)rrXrIrPrYrZr[rrr load_compileds  r^cCstjj|rtjddtjdd}xU|D]5}tjj|d|}tjj|r=Pq=q=Wtdj |nt j ||dg}t |}|t jkr|jt j|S|jSdS)z**DEPRECATED**Nr@z{!r} is not a packagesubmodule_search_locations)r=r(r>rr4r5joinexists ValueErrorformatrrQrr#rRrSrT)rr(r6 extensionrYrZrrr load_packages   rec Cs|\}}}|rI|jd  s1d|krItdj|n?|dkr|tthkrdj|}t|n|tkrt|||S|tkrt|||S|tkrtdk r|dkr t |d}t|||SWdQXqt|||Sni|t kr8t ||S|t krNt |S|tkrdt|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. r0U+zinvalid file open mode {!r}Nz.file object required for import (type code {})r+z*Don't know how to import {} (type code {})r)r0rf) startswithrbrcr1r2r\r^r,r rL PKG_DIRECTORYre C_BUILTINr PY_FROZENrr<) rrIfilenameZdetailssuffixmodetype_msgZ opened_filerrr load_modules."         rqc Cs,t|ts-tdjt|n9t|tdtfsftdjt|n|dkrt|rddddtffSt |rddddt ffSt j }nx|D]}t j j||}xbdtjdgD]M}d|}t j j||}t j j|rd|ddtffSqWxRtD]D\}}}||} t j j|| }t j j|rSPqSqSWqPqWttj|d|d} d |krt|d } tj| jd} WdQXnt||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%'list' must be None or a list, not {}r;z.pyrr@rbr+encoding) isinstancestr TypeErrorrctypelist RuntimeErrorr rjr rkr#r(r=r`rr5isfilerir9r<rrLtokenizedetect_encodingreadline) rr(entryZpackage_directoryrmZpackage_file_nameZ file_pathrnro file_namersrIrrrrBs@          rBcCs tj|S)zw**DEPRECATED** Reload the module and return it. The module must have been successfully imported before. ) importlibreload)r[rrrr3sr)7rF_imprrrrrrrr r r r r<importlib._bootstrapr rrrrrr=r#r{rwarningswarnPendingDeprecationWarningZ SEARCH_ERRORr1r2r,Z PY_RESOURCErirjrkZPY_CODERESOURCEZIMP_HOOKr r"r&r'r*r9r:rGrUrOr\r]r^rerqrBrrrrrsTF               #4