mņ %U²Ic@s*dZdkZdkZdkZdkZdkZdddgZedƒZeeƒZ dfd„ƒYZ dfd„ƒYZ e odpd Z d e Zd „Zdaad „Zd „Zd„Zde fd„ƒYZde fd„ƒYZd„Zdfd„ƒYZd„Zd„ZdS(s Import utilities Exported classes: ImportManager Manage the import process Importer Base class for replacing standard import functions BuiltinImporter Emulate the import mechanism for builtin and frozen modules DynLoadSuffixImporter Nt ImportManagertImportertBuiltinImportertcBsqtZdZeeƒd„Zd„Zd„ZeZ ed„Z eeed„Z d„Z d„Z d„ZRS( sManage the import process.cCsGt|tƒot|ƒ}n|d|_||_|i|dtj o2|i|dƒ} | ptd|‚q¦nXt|ƒdjo.|p| Sn| iidƒp| Sqēn| iidƒ}|o|i| |d|ƒSnt|ƒdjo8t| |dƒo$|ot| |dƒSqf| Sntd|‚dS( s5Python calls this hook to locate and import a module.t.isNo module named it __ispkg__t __importer__iN(tfqnametsplittpartsR t_determine_import_contexttglobalstparentR%t _do_importtfromlisttmoduletsystmodulest top_moduletKeyErrort_import_top_modulet ImportErrortlent__dict__tgettimportert_finish_importthasattrtgetattr( R R&R*tlocalsR-R+R(R.R8R1((R R Ss4  'cCsø| p|idƒ odSn|d}|do,ti|}||ijpt‚|Sn|i dƒ}|djodSn|| }ti|}|i |jpt‚|S(sJReturns the context in which a module should be imported. The context could be a loaded (package) module and the imported module will be looked for within that package. The context could also be None, meaning there is no context -- the module should be looked for as a "top-level" module. R%t__name__R$R#i’’’’N( R*R7Rt parent_fqnameR/R0R+R6RtrfindtiR=(R R*R+R@R>((R R)’s      cCs_xXtiD]M}t|tƒo|ii||ƒ}n|i |ƒ}|o|Sq q WdS(N( R/tpathtitemRt _StringTypeR Rtimport_from_dirtnameR.t import_topR(R RER.RB((R R3¹s  cCs*|iidƒ}|pntd‚dS(s*Python calls this hook to reload a module.R%sreload not yet implementedN(R.R6R7R8t SystemError(R R.R8((R t _reload_hookÅs (R=t __module__t__doc__Rt __builtin__R RRRRR"R R)R3RH(((R Rs    ? ' cBsVtZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( s3Base class for replacing standard import functions.cCs|id||ƒS(sImport a top-level module.N(R t _import_oneRRE(R RE((R RFŁscCsC|i||ƒ}|p|Sn|io|i||ƒn|S(N(R t _load_tailttopR(tbottomR-R$t_import_fromlist(R RNR(R-RO((R R9įs  cCs€yti|SWntj onX|i|||ƒ}|djodSn|i ||ƒ}|ot |||ƒn|S(sImport a single module.N( R/R0R&R2R tget_codeR+tmodnametresultRt_process_resultR.tsetattr(R R+RRR&R.RS((R RLs cBsĢ|\}}}e|eƒ}|o |}nei|ƒ}||_ ||_ |i i|ƒ|ei|<|p>y||i UWq²|eijoei|=n‚q²Xnei|}||_|S(N(tispkgtcodetvaluesRRt is_moduleR.Rt new_moduleR&R R%R$R6tupdateR/R0R=(R t.2R&RVRWRXR.RY((R RTs$       cCsUxN|D]F}d|i|f}|i|||ƒ}|ptd|‚qqW|S(sˆImport the rest of the modules, down from the top-level module. Returns the last module in the dotted list of modules. s%s.%ssNo module named N(R(tparttmR=R&R RLR4(R R^R(R&R]((R RM=scCs­d|jo)t|ƒt|iidgƒƒ}nxp|D]h}|djoUt||ƒ oDd|i|f}|i |||ƒ}|pt d|‚q„q=q=WdS(s*Import any sub-modules in the "from" list.t*t__all__s%s.%sscannot import name N( R-tlisttpackageR6R7tsubR:R=tsubnameR RLtsubmodR4(R RbR-RcRdRe((R RPIs )cCsV|d}|id|}|i|||ƒ}|pdSn|i ||d|ƒS(sØAttempt to import the module relative to parent. This method is used when the import context specifies that imported the parent module. iR#iN( R(ttop_nameR+R=t top_fqnameR RLR1RR9R-(R R+R(R-RfRgR1((R R,[s cCs td‚dS(s£Find and retrieve the code for the given module. parent specifies a parent module to define a context for importing. It may be None, indicating no particular context for the search. modname specifies a single module (not dotted) within the parent. fqname specifies the fully-qualified module name. This is a (potentially) dotted name from the "root" of the module namespace down to the modname. If there is no parent, then modname==fqname. This method should return None, or a 3-tuple. * If the module was not found, then None should be returned. * The first item of the 2- or 3-tuple should be the integer 0 or 1, specifying whether the module that was found is a package or not. * The second item is the code object for the module (it will be executed within the new module's namespace). This item can also be a fully-loaded module object (e.g. loaded from a shared lib). * The third item is a dictionary of name/value pairs that will be inserted into new module before the code object is executed. This is provided in case the module's code expects certain values (such as where the module was found). When the second item is a module object, then these names/values will be inserted *after* the module has been loaded/initialized. sget_code not implementedN(t RuntimeError(R R+RRR&((R RQns( R=RIRJRFR9RLRTRMRPR,RQ(((R RÖs   #  $  tctos.pycCsīt|dƒiƒ}|o|ddjo|d}nti||dƒ}yt|tdƒ}Wnt j onoX|i dƒ|i t i d|ƒƒti||ƒ|iƒ|iddƒ|i tiƒƒ|iƒ|S( sNCompile (and cache) a Python source file. The file specified by is compiled to a code object and returned. Presuming the appropriate privileges exist, the bytecodes will be saved back to the filesystem for future imports. The source file's modification timestamp must be provided as a Long value. trUi’’’’s texectwbts