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