mς DγΈEc@sLdZdkZd„Zd„Zd„ZdkZeidƒiZ[dS(s(Substitution support for ZConfig values.NcCs‘d|joŒd}|}xu|omt|ƒ\}}}}||7}|o@|i|ƒ}|djot i ||ƒ‚n||7}qqW|Sn|SdS(s.Interpolate variables from `mapping` into `s`.t$tN( tstresulttrestt_splittptnametnamecasetmappingtgettvtNonetZConfigtSubstitutionReplacementError(RR RRRRR R((t3/data/zmath/zope/lib/python/ZConfig/substitution.pyt substitutes   cCs/t|ƒ}|o|iƒ|jSntSdS(s/Return True iff s is a valid substitution name.N(t _name_matchRtmtgrouptFalse(RR((Rtisname%s  cCs‘d|jop|idƒ}||d|d!}|djotidƒ‚n|djo$||d dd||dfSn|| }|djo~t||dƒ}|ptidƒ‚n|i dƒ}|i ƒd}|i d |dƒptid |ƒ‚q_nIt||dƒ}|ptid ƒ‚n|i dƒ}|i ƒ}||iƒ|||fSn|dddfSdS( NRiiRs!illegal lone '$' at end of sourcet{s'${' not followed by nameit}s'${%s' not followed by '}'s'$' not followed by '$' or name(RtfindtitcR tSubstitutionSyntaxErrorR tprefixRRRRtendt startswithtlower(RRRRRR((RR.s.   $   s[a-zA-Z_][a-zA-Z0-9_]*( t__doc__R RRRtretcompiletmatchR(RR!RR RR((Rt?s   &