3 \) @sdZddlmZmZmZmZmZmZmZm Z m Z yddlm Z Wne k rXdZ YnXddl mZmZmZmZddlmZddlmZddlmZddlZddlZddlZddlZddlZddlZejd ed d dZd Zd Z d Z!dZ"dZ#dZ$dZ%dZ&dZ'ddZ(ddZ)ddZ*d8ddZ+ddZ,ddZ-Gd d!d!Z.Gd"d#d#Z/Gd$d%d%e/ej0Z1d9d&d'Z2Gd(d)d)e/eZ3d:d*d+Z4d,d-Z5d.d/Z6d;d0d1Z7d2d3Z8d4d5Z9e rdksz get_suffixes..cSsg|]}|dtfqS)r) PY_SOURCE)r3r4r r r!r5lscSsg|]}|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. cCs2|dkrtdddntjj|r.td|ddS)Nzempty pathname)r.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@rsr@cs.eZdZdZdfdd ZfddZZS)_HackedGetDatazMCompatibility support for 'file' arguments of various load_*() functions.Ncstj||||_dS)N)superrFfile)rErGr.rO) __class__r r!rFsz_HackedGetData.__init__c sX|jrH||jkrH|jjs |j}nt|jd|_}| |jSQRXn tj|SdS)z;Gross hack to contort loader to deal w/ load_*()'s bad API.r6N)rOr.closedopenreadrNget_data)rEr.rO)rPr r!rTsz_HackedGetData.get_data)N)rIrJrKrLrFrT __classcell__r r )rPr!rMsrMc@seZdZdZdS)_LoadSourceCompatibilityz5Compatibility support for implementing load_source().N)rIrJrKrLr r r r!rVsrVcCs\t|||}tj|||d}|tjkr8t|tj|}nt|}tj|||_ |j |j _ |S)N)loader) rVrspec_from_file_locationr%modulesr rrSourceFileLoader __loader____spec__rW)rpathnamerOrWspecmoduler r r! load_sources   r`c@seZdZdZdS)_LoadCompiledCompatibilityz7Compatibility support for implementing load_compiled().N)rIrJrKrLr r r r!rasracCsZt|||}tj|||d}|tjkr8t|tj|}nt|}t|||_|j|j _ |S)z**DEPRECATED**)rW) rarrXr%rYr rrr[r\rW)rr]rOrWr^r_r r r! load_compileds    rbcCstjj|rhtjddtjdd}x>|D](}tjj|d|}tjj|r.|}Pq.Wtdj |t j ||gd}|t j krt|t j |St|SdS)z**DEPRECATED**NrFz{!r} is not a package)submodule_search_locations)rCr.rDrr:r;joinexists ValueErrorformatrrXr%rYr r)rr.r< extensionZ init_pathr^r r r! load_packages     ric Cs|\}}}|r2|jd  s"d|kr2tdj|n|dkrZ|tthkrZdj|}t|n|tkrnt|||S|tkrt|||S|tkrtdk r|dkrt |d}t|||SQRXn t|||SnL|t krt ||S|t krt |S|tkrt|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)r6rj) startswithrfrgr7r8r`rbr2 load_dynamicrR PKG_DIRECTORYri C_BUILTIN init_builtin PY_FROZENrrB) rrOfilenameZdetailssuffixmodetype_msgZ opened_filer r r! load_modules.         rwc Cst|tstdjt|n$t|tdtfsBtdjt||dkrt|rbddddtffSt |rzddddt ffSt j }x|D]}t j j||}xHdtjdgD]6}d|}t j j||}t j j|rd|ddtffSqWx:tD].\}}}||} t j j|| }t j j|rPqWqPqWttj||dd} d |krjt|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.pyrrF)rbr1)encoding) isinstancestr TypeErrorrgtypelist RuntimeErrorrror rqr%r.rCrdrr;isfilernr?rBr rRtokenizedetect_encodingreadline) rr.entryZpackage_directoryrsZpackage_file_nameZ file_pathrtru file_nameryrOr 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|Stk rdSXdS)zl**DEPRECATED** Load and return a built-in module by name, or None is such module doesn't exist N)rrB)rr r r!rp>srpcCs0ddl}|jj||}|jj|||d}t|S)z:**DEPRECATED** Load an extension module. rN)rrWorigin)importlib.machineryrExtensionFileLoader ModuleSpecr)rr.rOrrWr^r r r!rmKs  rm)N)N)N)N)N);rL_imprrrrrrrr r r rBZimportlib._bootstrapr r rrZimportlib._bootstrap_externalrrrrrCr%rrr*warnDeprecationWarningZ SEARCH_ERRORr7r8r2Z PY_RESOURCErnrorqZPY_CODERESOURCEZIMP_HOOKr"r$r(r-r0r?r@rMrZrVr`rarbrirwrHrrprmr r r r!s^,          # 4