3
\me @ s
U d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm Z d dl
mZ ey$d dl
mZ d dl
mZ dZeZW n eefk
r d ZeZY nX ejeZejd
ejZejdZdZG d
d deZdd Zdd Z dd Z!dddZ"dd Z#dddZ$dS ) N)Any)
type_utils)util)
write_file)DebugUndefined)TemplateTFz##\s*template:(.*)z)\$\{([A-Za-z0-9_.]+)\}|\$([A-Za-z0-9_.]+)zCI_MISSING_JINJA_VAR/c @ s e Zd ZdZdd Zdd ZdS )UndefinedJinjaVariablez>Class used to represent any undefined jinja template variable.c C s dt | jf S )Nz%s%s)MISSING_JINJA_PREFIX_undefined_name)self r /usr/lib/python3.6/templater.py__str__2 s zUndefinedJinjaVariable.__str__c C s( t |jtd}tdj| j|dd S )N zhUndefined jinja variable: "{this}-{other}". Jinja tried subtraction. Perhaps you meant "{this}_{other}"?)thisother)strreplacer TypeErrorformatr
)r r r r r
__sub__5 s zUndefinedJinjaVariable.__sub__N)__name__
__module____qualname____doc__r r r r r r
r / s r c s fdd}t j|| S )zThis 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'.
c s | j d}|d kr| j d}|d kr,tdtj|jd} }xBt|dkr|j }t|tsxt d|t
j||f || }qBW |j }t|tst d||t
j|f t|| S )N z,Match encountered but no valid group present.zRCan not traverse into non-dictionary '%s' of type %s while looking for subkey '%s'z