diff --git a/calculate/templates/template_processor.py b/calculate/templates/template_processor.py index bedcdfb..ac4387f 100644 --- a/calculate/templates/template_processor.py +++ b/calculate/templates/template_processor.py @@ -2763,7 +2763,15 @@ class DirectoryProcessor: ("Action parameter is not set for template:" " {0}").format(template_path)) return False - elif parameters.action not in self.action: + elif parameters.action.startswith('!'): + action_matching = (parameters.action[1:].strip() not in + self.action) + elif parameters.action not in self.action: + action_matching = False + else: + action_matching = True + + if not action_matching: self.output.set_warning( ("Action parameter value '{0}' does not match its" " current value{1} '{2}'. Template: {3}").format( diff --git a/tests/templates/test_directory_processor.py b/tests/templates/test_directory_processor.py index ea24668..8f21116 100644 --- a/tests/templates/test_directory_processor.py +++ b/tests/templates/test_directory_processor.py @@ -1470,6 +1470,17 @@ class TestDirectoryProcessor: directory_processor.process_template_directories() assert os.path.exists(join_paths(CHROOT_PATH,'/etc/dir_63/file_0')) + def test_using_excepting_action_values(self): + datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH, + 'templates_47') + directory_processor = DirectoryProcessor( + 'update', + datavars_module=datavars, + package='test-category/test-package' + ) + directory_processor.process_template_directories() + assert os.path.exists(join_paths(CHROOT_PATH,'/etc/dir_65/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_47/install/.calculate_directory b/tests/templates/testfiles/test_dir_processor_root/templates_47/install/.calculate_directory new file mode 100644 index 0000000..e1f74a4 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_47/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_47/install/dir_64/file_0 b/tests/templates/testfiles/test_dir_processor_root/templates_47/install/dir_64/file_0 new file mode 100644 index 0000000..5b18600 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_47/install/dir_64/file_0 @@ -0,0 +1,2 @@ +{% calculate append = 'join', format = 'raw' %} +Something I can never have diff --git a/tests/templates/testfiles/test_dir_processor_root/templates_47/not_install/.calculate_directory b/tests/templates/testfiles/test_dir_processor_root/templates_47/not_install/.calculate_directory new file mode 100644 index 0000000..5d98bcb --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_47/not_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_47/not_install/dir_65/file_0 b/tests/templates/testfiles/test_dir_processor_root/templates_47/not_install/dir_65/file_0 new file mode 100644 index 0000000..5b18600 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_47/not_install/dir_65/file_0 @@ -0,0 +1,2 @@ +{% calculate append = 'join', format = 'raw' %} +Something I can never have