Mc@sCdZddlZddlZddlZddZdZdS(sadds autohandler functionality to Mako templates. requires that the TemplateLookup class is used with templates. usage: <%! from mako.ext.autohandler import autohandler %> <%inherit file="${autohandler(template, context)}"/> or with custom autohandler filename: <%! from mako.ext.autohandler import autohandler %> <%inherit file="${autohandler(template, context, name='somefilename')}"/> iNt autohandlercCs,|j}|jj}|jsMy|jt||fSWqMtk rIqMXntjdt j ||g}xt |rddj |}||krt ||r|js|jjt||f|S|Snt |dkrPn|g|d)qrW|js$|jjt||fdSdSdS(Ns([^/]+)t/ii(tlookuptmodulet _template_uritfilesystem_checkst _uri_cacheRtKeyErrortretfindallt posixpathtdirnametlentjoint _file_existst setdefaulttNone(ttemplatetcontexttnameRRttokenstpath((s:/usr/lib/python2.7/vendor-packages/mako/ext/autohandler.pyRs,    "    cCsOtjdd|}x3|jD]$}tjj|d|rtSqWtSdS(Ns^/tR(Rtsubt directoriestosRtexiststTruetFalse(RRtpsubtd((s:/usr/lib/python2.7/vendor-packages/mako/ext/autohandler.pyR:s (t__doc__R RRRR(((s:/usr/lib/python2.7/vendor-packages/mako/ext/autohandler.pyts$