You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
897 B
27 lines
897 B
from calculate.templates.template_engine import TemplateEngine, Variables,\
|
|
ConditionFailed, DIR, FILE
|
|
from calculate.templates.template_processor import TemplateAction
|
|
|
|
template_text = '''{% calculate append = 'join', path = '/etc/file.conf' %}
|
|
{% calculate package = "dev-lang/python" %}
|
|
{% calculate name = 'filename', format = 'samba' %}
|
|
[section one]
|
|
parameter_1 = value_1
|
|
!parameter_2 = value_2
|
|
'''
|
|
|
|
APPENDS_SET = TemplateAction().available_appends
|
|
|
|
template_engine = TemplateEngine(appends_set=APPENDS_SET)
|
|
template_engine.process_template_from_string(template_text, FILE)
|
|
template_parameters = template_engine.parameters
|
|
target_path = '/etc/dir/file.conf'
|
|
|
|
|
|
def use_template(target_path, parameters, chroot_path):
|
|
print('Template parameters:')
|
|
parameters.print_parameters_for_debug()
|
|
|
|
|
|
use_template(target_path, template_parameters)
|