U e5d()@sdZddlmZmZmZmZmZmZmZm Z m Z zddlm 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_SOURCEr7r!r!r"r:lscSsg|]}|dtfqSr4) PY_COMPILEDr7r!r!r"r:ms)rEXTENSION_SUFFIXESSOURCE_SUFFIXESBYTECODE_SUFFIXES) extensionssourcebytecoder!r!r" get_suffixesisrDc@s eZdZdZddZddZdS) NullImporterz-**DEPRECATED** Null import object. cCs2|dkrtdddntj|r.td|ddS)Nzempty pathnamer2zexisting directory) ImportErrorosr/isdir)selfr/r!r!r"__init__zs zNullImporter.__init__cCsdS)zAlways returns None.Nr!)rJfullnamer!r!r" find_moduleszNullImporter.find_moduleN)__name__ __module__ __qualname____doc__rKrMr!r!r!r"rErsrEcs.eZdZdZdfdd ZfddZZS)_HackedGetDatazMCompatibility support for 'file' arguments of various load_*() functions.Ncst||||_dS)N)superrKfile)rJrLr/rT __class__r!r"rKsz_HackedGetData.__init__c s||jrl||jkrl|jjs0|j}d|jkr0||jjrJt|jd|_}||W5QRSQRXn t|SdS)z;Gross hack to contort loader to deal w/ load_*()'s bad API.br5N) rTr/closedmodecloseopenreadrSget_data)rJr/rTrUr!r"r]s z_HackedGetData.get_data)N)rNrOrPrQrKr] __classcell__r!r!rUr"rRsrRc@seZdZdZdS)_LoadSourceCompatibilityz5Compatibility support for implementing load_source().NrNrOrPrQr!r!r!r"r_sr_cCs\t|||}tj|||d}|tjkr8t|tj|}nt|}t|||_ |j |j _ |S)Nloader) r_rspec_from_file_locationr&modulesr rrSourceFileLoader __loader____spec__rbr pathnamerTrbspecmoduler!r!r" load_sources   rlc@seZdZdZdS)_LoadCompiledCompatibilityz7Compatibility support for implementing load_compiled().Nr`r!r!r!r"rmsrmcCsZt|||}tj|||d}|tjkr8t|tj|}nt|}t|||_|j|j _ |S)r3ra) rmrrcr&rdr rrrfrgrbrhr!r!r" load_compileds    rncCstj|rftjddtjdd}|D]*}tj|d|}tj|r,|}qfq,td |t j ||gd}|t j krt|t j |St|SdS)r3NrKz{!r} is not a package)submodule_search_locations)rHr/rIrr?r@joinexists ValueErrorformatrrcr&rdr r)r r/rA extensionZ init_pathrjr!r!r" load_packages      ruc Cs$|\}}}|r0|dr d|kr0td|n|dkrX|tthkrXd|}t|n|tkrlt|||S|tkrt|||S|tkrtdk r|dkrt |d}t|||W5QRSQRXn t|||SnN|t krt ||S|t krt |S|tkrt|Sd||}t||ddS) z**DEPRECATED** Load a module, given information returned by find_module(). The module name must include the full package name, if any. )r;U+zinvalid file open mode {!r}Nz.file object required for import (type code {})r5z*Don't know how to import {} (type code {})r) startswithrrrsr<r=rlrnr6 load_dynamicr[ PKG_DIRECTORYru C_BUILTIN init_builtin PY_FROZENrrG) r rTfilenameZdetailssuffixrYtype_msgZ opened_filer!r!r" load_modules.           rc Cst|tstdt|n$t|tdtfsBtdt||dkrt|rbddddtffSt |rzddddt ffSt j }|D]}t j ||}dtjdfD]>}d|}t j ||}t j |rd|ddtffSqtD]2\}}}||} t j || }t j |rq qqq:qtt||dd} d |krnt|d } t| jd} W5QRXt||| 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 {}rFz.pyrrKrrWr5)encoding) isinstancestr TypeErrorrstypelist RuntimeErrorrr{r r}r&r/rHrprr@isfilerzrDrGr r[tokenizedetect_encodingreadline) r r/entryZpackage_directoryrZpackage_file_nameZ file_pathrYr file_namerrTr!r!r"rMsB     rMcCs t|S)zw**DEPRECATED** Reload the module and return it. The module must have been successfully imported before. ) importlibreload)rkr!r!r"r2srcCs&z t|WStk r YdSXdS)zl**DEPRECATED** Load and return a built-in module by name, or None is such module doesn't exist N)rrGrr!r!r"r|=s r|cCs0ddl}|j||}|jj|||d}t|S)z:**DEPRECATED** Load an extension module. rN)r rborigin)importlib.machineryrExtensionFileLoader ModuleSpecr)r r/rTrrbrjr!r!r"ryJsry)N)N)N)N)N);rQ_imprrrrrrrr r r rGZimportlib._bootstrapr r rrZimportlib._bootstrap_externalrrrrrHr&rrr+warnDeprecationWarningZ SEARCH_ERRORr<r=r6Z PY_RESOURCErzr{r}ZPY_CODERESOURCEZIMP_HOOKr#r%r)r.r1rDrErRrer_rlrmrnrurrMrr|ryr!r!r!r"sb,         # 4