From 920fc6c819d5f0e0ecc27adb6e7b8fea72b30eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=81?= Date: Fri, 20 Nov 2020 11:08:36 +0300 Subject: [PATCH] Default 'append' and 'format' parameters values are added. fixed #22 --- calculate/templates/template_processor.py | 14 ++++++++++---- .../templates_33/install/dir_34/file_0 | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/calculate/templates/template_processor.py b/calculate/templates/template_processor.py index fcd94c7..4c585dd 100644 --- a/calculate/templates/template_processor.py +++ b/calculate/templates/template_processor.py @@ -946,6 +946,7 @@ class TemplateExecutor: join_before=False, replace=False) -> None: '''Метод описывающий действия при append = "join", если шаблон -- файл. Объединяет шаблон с целевым файлом.''' + print("join file") input_path = template_object.input_path output_path = template_object.output_path @@ -2449,10 +2450,15 @@ class DirectoryProcessor: template_package = Package(directory_parameters.package, chroot_path=self.cl_chroot_path) - if (not template_parameters.append and - not template_parameters.run and - not template_parameters.exec): - template_parameters.set_parameter({'append': 'join'}) + if not template_parameters.run and not template_parameters.exec: + if not template_parameters.format: + template_parameters.set_parameter({'format': 'raw'}) + if not template_parameters.append: + if template_parameters.format == "raw": + template_parameters.set_parameter( + {'append': 'replace'}) + else: + template_parameters.set_parameter({'append': 'join'}) if template_parameters.append != 'skip': # Выполняем действия, указанные в шаблоне. diff --git a/tests/templates/testfiles/test_dir_processor_root/templates_33/install/dir_34/file_0 b/tests/templates/testfiles/test_dir_processor_root/templates_33/install/dir_34/file_0 index d253f96..253e019 100644 --- a/tests/templates/testfiles/test_dir_processor_root/templates_33/install/dir_34/file_0 +++ b/tests/templates/testfiles/test_dir_processor_root/templates_33/install/dir_34/file_0 @@ -1 +1 @@ -{% calculate merge = 'test-category/test-package' -%} +{% calculate append = "skip", merge = 'test-category/test-package' -%}