Viewing File: /usr/lib/python2.7/site-packages/cloudinit/templater.pyo

ó
oBú]c@sddlZddlZyddlmZeZWneefk
rQe	ZnXy:ddl
mZddlmZ
ddlmZeZWn9eefk
rÇddlmZeZe	ZeZnXddlmZddlmZddlmZejeƒZejd	ejƒZejd
ƒZ dZ!edefd
„ƒYƒZ"d„Z#d„Z$d„Z%dd„Z&dd„Z'd„Z(dS(iÿÿÿÿN(tTemplate(timplements_to_string(tDebugUndefined(tidentity(tlog(t
type_utils(tutils##\s*template:(.*)s)\$\{([A-Za-z0-9_.]+)\}|\$([A-Za-z0-9_.]+)uCI_MISSING_JINJA_VAR/tUndefinedJinjaVariablecBs eZdZd„Zd„ZRS(s>Class used to represent any undefined jinja template variable.cCsdt|jfS(Nu%s%s(tMISSING_JINJA_PREFIXt_undefined_name(tself((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pyt__str__1scCs=t|ƒjtdƒ}tdjd|jd|ƒƒ‚dS(NtshUndefined jinja variable: "{this}-{other}". Jinja tried subtraction. Perhaps you meant "{this}_{other}"?tthistother(tstrtreplaceRt	TypeErrortformatR	(R
R((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pyt__sub__4s	(t__name__t
__module__t__doc__RR(((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pyR-s	cs‡fd†}tj||ƒS(sìThis does simple replacement of bash variable like templates.

    It identifies patterns like ${a} or $a and can also identify patterns like
    ${a.b} or $a.b which will look for a key 'b' in the dictionary rooted
    by key 'a'.
    cs|jdƒ}|dkr-|jdƒ}n|dkrHtdƒ‚ntj|jdƒƒ}ˆ}x`t|ƒdkrÈ|jƒ}t|t	ƒs»t
d|tj|ƒ|fƒ‚n||}qiW|jƒ}t|t	ƒs	t
d||tj|ƒfƒ‚nt
||ƒS(Niis,Match encountered but no valid group presentt.sRCan not traverse into non-dictionary '%s' of type %s while looking for subkey '%s's<Can not extract key '%s' from non-dictionary '%s' of type %s(tgrouptNonetRuntimeErrortcollectionstdequetsplittlentpopleftt
isinstancetdictRttutobj_nameR(tmatchtnametpathtselected_paramstkey(tparams(s7/usr/lib/python2.7/site-packages/cloudinit/templater.pytreplacerDs*(t
BASIC_MATCHERtsub(tcontentR)R*((R)s7/usr/lib/python2.7/site-packages/cloudinit/templater.pytbasic_render<scCsvd„}d„}|jdƒdkrB|jddƒ\}}n|}d}tj|ƒ}|s“trƒtjdƒd||fSd	t|fSnß|jdƒj	ƒj
ƒ}|dkrÍtd|ƒ‚n|d
krútrútj
dƒd	t|fS|d
krtrd
||fS|dkrFtrFtj
d
ƒd	t|fS|dkretred||fSd	t|fSdS(NcSst|d|gƒjƒS(Nt
searchList(t	CTemplatetrespond(R-R)((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pytcheetah_renderdscSs>|jdƒrdnd}t|dtdtƒj||S(Ns
Rt	undefinedttrim_blocks(tendswitht	JTemplateRtTruetrender(R-R)tadd((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pytjinja_rendergs	s
iÿÿÿÿiRs3Using Cheetah as the renderer for unknown template.tcheetahtbasictjinjas.Unknown template rendering type '%s' requestedscJinja not available as the selected renderer for desired template, reverting to the basic renderer.seCheetah not available as the selected renderer for desired template, reverting to the basic renderer.(R=R;R<(tfindRtTYPE_MATCHERR$tCHEETAH_AVAILABLEtLOGtdebugR.Rtlowertstript
ValueErrortJINJA_AVAILABLEtwarning(ttextR2R:tidenttrestt
type_matcht
template_type((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pytdetect_templatebs6		








cCs\|si}nttj|dtƒjdƒƒ\}}}tjd||ƒ|||ƒS(Ntdecodesutf-8s+Rendering content of '%s' using renderer %s(RMRt	load_filetFalseRNRARB(tfnR)RLtrendererR-((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pytrender_from_files	*i¤cCs)t||ƒ}tj||d|ƒdS(Ntmode(RSRt
write_file(RQtoutfnR)RTtcontents((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pytrender_to_file›scCs)t||ƒ}tj||d|ƒdS(spRender string (or py2 unicode) to file.
    Warning: py2 str with non-ascii chars will cause UnicodeDecodeError.RTN(t
render_stringRRU(R-RVR)RTRW((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pytrender_string_to_file scCs1|si}nt|ƒ\}}}|||ƒS(shRender string (or py2 unicode).
    Warning: py2 str with non-ascii chars will cause UnicodeDecodeError.(RM(R-R)t_template_typeRR((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pyRY§s	()RtretCheetah.TemplateRR0R7R@tImportErrortAttributeErrorRPtjinja2.runtimeRtjinja2R6Rt
JUndefinedRFtcloudinit.helpersRtobjectt	cloudinitRtloggingRR"Rt	getLoggerRRAtcompiletIR?R+RRR.RMRSRXRZRY(((s7/usr/lib/python2.7/site-packages/cloudinit/templater.pyt<module>
s>



	&	-	
Back to Directory File Manager