From 68cc128d964cd71fa72e0c50ec34269561d7b9aa 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: Wed, 25 Nov 2020 14:58:58 +0300 Subject: [PATCH] Added ignoring files from the base templates directory. fixed #32 --- calculate/templates/template_processor.py | 2 ++ tests/templates/test_directory_processor.py | 11 +++++++++++ .../templates_46/file_to_ignore | 1 + .../templates_46/install/.calculate_directory | 1 + .../templates_46/install/dir_63/file_0 | 2 ++ 5 files changed, 17 insertions(+) create mode 100644 tests/templates/testfiles/test_dir_processor_root/templates_46/file_to_ignore create mode 100644 tests/templates/testfiles/test_dir_processor_root/templates_46/install/.calculate_directory create mode 100644 tests/templates/testfiles/test_dir_processor_root/templates_46/install/dir_63/file_0 diff --git a/calculate/templates/template_processor.py b/calculate/templates/template_processor.py index 96a14d4..bedcdfb 100644 --- a/calculate/templates/template_processor.py +++ b/calculate/templates/template_processor.py @@ -2135,6 +2135,8 @@ class DirectoryProcessor: entries = os.scandir(self.base_directory) for node in entries: + if node.is_file(): + continue self.directory_tree = {} parameters = ParametersContainer() if self._namespace: diff --git a/tests/templates/test_directory_processor.py b/tests/templates/test_directory_processor.py index c65b83b..ea24668 100644 --- a/tests/templates/test_directory_processor.py +++ b/tests/templates/test_directory_processor.py @@ -1459,6 +1459,17 @@ class TestDirectoryProcessor: output_text = output_file.read() assert output_text == expected_output + def test_ignoring_files_in_templates_base_directory(self): + datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH, + 'templates_46') + directory_processor = DirectoryProcessor( + 'install', + datavars_module=datavars, + package='test-category/test-package' + ) + directory_processor.process_template_directories() + assert os.path.exists(join_paths(CHROOT_PATH,'/etc/dir_63/file_0')) + def test_view_tree(self): list_path = join_paths(CHROOT_PATH, '/etc') show_tree(list_path) diff --git a/tests/templates/testfiles/test_dir_processor_root/templates_46/file_to_ignore b/tests/templates/testfiles/test_dir_processor_root/templates_46/file_to_ignore new file mode 100644 index 0000000..104db85 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_46/file_to_ignore @@ -0,0 +1 @@ +Suzumiya Haruhi no Yuutsu diff --git a/tests/templates/testfiles/test_dir_processor_root/templates_46/install/.calculate_directory b/tests/templates/testfiles/test_dir_processor_root/templates_46/install/.calculate_directory new file mode 100644 index 0000000..e1f74a4 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_46/install/.calculate_directory @@ -0,0 +1 @@ +{% calculate action = "install", append = "skip", package = "test-category/test-package" %} diff --git a/tests/templates/testfiles/test_dir_processor_root/templates_46/install/dir_63/file_0 b/tests/templates/testfiles/test_dir_processor_root/templates_46/install/dir_63/file_0 new file mode 100644 index 0000000..5b18600 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_46/install/dir_63/file_0 @@ -0,0 +1,2 @@ +{% calculate append = 'join', format = 'raw' %} +Something I can never have