ó [Z-Lc@sdZddlZddlZddlZddlZddlZddlmZddl Z ddl Z ddlZddl m Z ddl mZddlmZddlmZeagad„Zd efd „ƒYZdd „Zd „Zedkr eƒndS(s¸ Provides some import hooks to allow Cheetah's .tmpl files to be imported directly like Python .py modules. To use these: import Cheetah.ImportHooks Cheetah.ImportHooks.install() i˙˙˙˙N(tRLock(t ImportManager(tDirOwner(tCompiler(tconvertTmplPathToModuleNamecCstj|ƒdS(N(t _cacheDirtappend(tcacheDir((s@/opt/freeware/lib/python2.7/site-packages/Cheetah/ImportHooks.pyt setCacheDir!stCheetahDirOwnercBs;eZeƒZejZejZdZd„Z d„Z RS(s.tmplcCsŰ|jƒzżtj||ƒ}|r)|Sx˜|jD]}tjj|j||ƒ}tjj|ƒr3y|j||ƒSWqŔt j ƒ}ddj|j ƒƒ}t dt ƒƒ‚qŔXq3q3WdSWd|jƒXdS(Ns s sVError while compiling Cheetah module %(name)s, original traceback follows: %(exc_txt)s(t _acquireLockRtgetmodttemplateFileExtensionstostpathtjointexistst_compilet tracebackt format_exct splitlinest ImportErrortlocalstNonet _releaseLock(tselftnametmodtextttmplPathtexc_txt((s@/opt/freeware/lib/python2.7/site-packages/Cheetah/ImportHooks.pyR /s$  cCsęttd|d|d|ƒƒ}tr”tjjtdt|ƒƒd}yt|dƒj|ƒWqšt k rt j dt j ƒ|}qšXn|}t|d|dƒ}tj|ƒ}|j|_trÝ||_n||_|S( Ntfilet moduleNamet mainClassNameis.pytws texec(tstrRRR RRRtopentwritetOSErrorRt print_exctsyststderrtcompilettypest ModuleTypet co_filenamet__file__t __orig_file__t__co__(RRRtcodeR/tcoR((s@/opt/freeware/lib/python2.7/site-packages/Cheetah/ImportHooks.pyRHs$      (s.tmpl( t__name__t __module__Rt_locktacquireR treleaseRR R R(((s@/opt/freeware/lib/python2.7/site-packages/Cheetah/ImportHooks.pyR (s     s.tmplcCsvtsr|t_ddl}t|jtjƒrr|jat j j dtƒt j ƒa t j ƒt jƒqrndS(s Install the Cheetah Import Hooksi˙˙˙˙Ni(t _installedR R t __builtin__t isinstancet __import__R,tBuiltinFunctionTypet __oldimport__Rt_globalOwnerTypestinsertt_managert setThreadedtinstall(R R:((s@/opt/freeware/lib/python2.7/site-packages/Cheetah/ImportHooks.pyRCes     cCs=ts9ddl}t|jtjƒr9t|_bq9ndS(s"Uninstall the Cheetah Import Hooksi˙˙˙˙N(R9R:R;R<R,t MethodTypeR>RA(R:((s@/opt/freeware/lib/python2.7/site-packages/Cheetah/ImportHooks.pyt uninstallvs   t__main__(s.tmpl(t__doc__R)tos.pathR R,R:timpt threadingRtstringRtCheetahRtCheetah.ImportManagerRtCheetah.CompilerRt#Cheetah.convertTmplPathToModuleNameRtFalseR9RRR RCRER4(((s@/opt/freeware/lib/python2.7/site-packages/Cheetah/ImportHooks.pyt s*         =