diff --git a/doc/service/file.md b/doc/service/file.md
index 435d88466..7c774d2f7 100644
--- a/doc/service/file.md
+++ b/doc/service/file.md
@@ -107,7 +107,13 @@ Il est possible de personnaliser les droits par défaut dans la [configuration d
## Désactiver la génération d'un fichier
-Il est possible de définir une [condition](../condition/README.md) de type "disabled_if_in" ou "disabled_if_not_in" sur une balise fichier :
+Il est possible de désactiver la génération d'un fichier avec l'attribut "disabled" :
+
+```
+/etc/squid/squid.conf
+```
+
+Il est aussi possible de définir une [condition](../condition/README.md) de type "disabled_if_in" ou "disabled_if_not_in" sur une balise fichier :
```
diff --git a/src/rougail/annotator/service.py b/src/rougail/annotator/service.py
index 5b7e302e9..62e76e04a 100644
--- a/src/rougail/annotator/service.py
+++ b/src/rougail/annotator/service.py
@@ -33,7 +33,7 @@ from rougail.error import DictConsistencyError
# a object's attribute has some annotations
# that shall not be present in the exported (flatened) XML
ERASED_ATTRIBUTES = ('redefine', 'namespace', 'xmlfiles', 'disabled', 'name', 'manage')
-ERASED_ATTRIBUTES2 = ('redefine', 'namespace', 'xmlfiles')
+ERASED_ATTRIBUTES2 = ('redefine', 'namespace', 'xmlfiles', 'disabled')
ALLOW_ATTRIBUT_NOT_MANAGE = ['file', 'engine', 'target']
@@ -152,11 +152,15 @@ class Annotator:
elt.xmlfiles,
)
family.variable = []
+ if hasattr(elt, 'disabled'):
+ disabled = elt.disabled
+ else:
+ disabled = False
activate_obj = self._generate_element('boolean',
None,
None,
'activate',
- True,
+ not disabled,
elt,
'.'.join([subpath, 'activate']),
)
diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd
index 4bb004dcd..0829d5cf2 100644
--- a/src/rougail/data/rougail.dtd
+++ b/src/rougail/data/rougail.dtd
@@ -74,6 +74,7 @@
+
diff --git a/tests/dictionaries/01base_file_disabled/00-base.xml b/tests/dictionaries/01base_file_disabled/00-base.xml
new file mode 100644
index 000000000..ebd0c707c
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/00-base.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ /etc/file
+ /etc/file2
+ /etc/file3
+
+
+
+
+
+ non
+
+
+
+
diff --git a/tests/dictionaries/01base_file_disabled/__init__.py b/tests/dictionaries/01base_file_disabled/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/dictionaries/01base_file_disabled/makedict/after.json b/tests/dictionaries/01base_file_disabled/makedict/after.json
new file mode 100644
index 000000000..255e30bc4
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/makedict/after.json
@@ -0,0 +1,38 @@
+{
+ "rougail.general.mode_conteneur_actif": {
+ "owner": "default",
+ "value": "non"
+ },
+ "services.test.files.file.name": {
+ "owner": "default",
+ "value": "/etc/file"
+ },
+ "services.test.files.file.activate": {
+ "owner": "default",
+ "value": true
+ },
+ "services.test.files.file2.name": {
+ "owner": "default",
+ "value": "/etc/file2"
+ },
+ "services.test.files.file2.activate": {
+ "owner": "default",
+ "value": true
+ },
+ "services.test.files.file3.name": {
+ "owner": "default",
+ "value": "/etc/file3"
+ },
+ "services.test.files.file3.activate": {
+ "owner": "default",
+ "value": false
+ },
+ "services.test.activate": {
+ "owner": "default",
+ "value": true
+ },
+ "services.test.manage": {
+ "owner": "default",
+ "value": true
+ }
+}
diff --git a/tests/dictionaries/01base_file_disabled/makedict/base.json b/tests/dictionaries/01base_file_disabled/makedict/base.json
new file mode 100644
index 000000000..1b8f6948c
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/makedict/base.json
@@ -0,0 +1,11 @@
+{
+ "rougail.general.mode_conteneur_actif": "non",
+ "services.test.files.file.name": "/etc/file",
+ "services.test.files.file.activate": true,
+ "services.test.files.file2.name": "/etc/file2",
+ "services.test.files.file2.activate": true,
+ "services.test.files.file3.name": "/etc/file3",
+ "services.test.files.file3.activate": false,
+ "services.test.activate": true,
+ "services.test.manage": true
+}
diff --git a/tests/dictionaries/01base_file_disabled/makedict/before.json b/tests/dictionaries/01base_file_disabled/makedict/before.json
new file mode 100644
index 000000000..255e30bc4
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/makedict/before.json
@@ -0,0 +1,38 @@
+{
+ "rougail.general.mode_conteneur_actif": {
+ "owner": "default",
+ "value": "non"
+ },
+ "services.test.files.file.name": {
+ "owner": "default",
+ "value": "/etc/file"
+ },
+ "services.test.files.file.activate": {
+ "owner": "default",
+ "value": true
+ },
+ "services.test.files.file2.name": {
+ "owner": "default",
+ "value": "/etc/file2"
+ },
+ "services.test.files.file2.activate": {
+ "owner": "default",
+ "value": true
+ },
+ "services.test.files.file3.name": {
+ "owner": "default",
+ "value": "/etc/file3"
+ },
+ "services.test.files.file3.activate": {
+ "owner": "default",
+ "value": false
+ },
+ "services.test.activate": {
+ "owner": "default",
+ "value": true
+ },
+ "services.test.manage": {
+ "owner": "default",
+ "value": true
+ }
+}
diff --git a/tests/dictionaries/01base_file_disabled/result/etc/file b/tests/dictionaries/01base_file_disabled/result/etc/file
new file mode 100644
index 000000000..4089fbcce
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/result/etc/file
@@ -0,0 +1,2 @@
+non
+non
diff --git a/tests/dictionaries/01base_file_disabled/result/etc/file2 b/tests/dictionaries/01base_file_disabled/result/etc/file2
new file mode 100644
index 000000000..4089fbcce
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/result/etc/file2
@@ -0,0 +1,2 @@
+non
+non
diff --git a/tests/dictionaries/01base_file_disabled/result/tmpfiles.d/0rougail.conf b/tests/dictionaries/01base_file_disabled/result/tmpfiles.d/0rougail.conf
new file mode 100644
index 000000000..8a8e63080
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/result/tmpfiles.d/0rougail.conf
@@ -0,0 +1,2 @@
+C /etc/file 0644 root root - /usr/local/lib/etc/file
+C /etc/file2 0644 root root - /usr/local/lib/etc/file2
diff --git a/tests/dictionaries/01base_file_disabled/tiramisu/base.py b/tests/dictionaries/01base_file_disabled/tiramisu/base.py
new file mode 100644
index 000000000..cb4a393c3
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/tiramisu/base.py
@@ -0,0 +1,38 @@
+from importlib.machinery import SourceFileLoader as _SourceFileLoader
+from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
+class func:
+ pass
+_loader = _SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
+_spec = _spec_from_loader(_loader.name, _loader)
+_func = _module_from_spec(_spec)
+_loader.exec_module(_func)
+for function in dir(_func):
+ if function.startswith('_'):
+ continue
+ setattr(func, function, getattr(_func, function))
+try:
+ from tiramisu3 import *
+except:
+ from tiramisu import *
+option_3 = StrOption(name="mode_conteneur_actif", doc="Description", default="non", properties=frozenset({"mandatory", "normal"}))
+option_2 = OptionDescription(name="general", doc="general", children=[option_3], properties=frozenset({"normal"}))
+option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
+option_8 = FilenameOption(name="name", doc="name", default="/etc/file")
+option_9 = BoolOption(name="activate", doc="activate", default=True)
+option_7 = OptionDescription(name="file", doc="file", children=[option_8, option_9])
+option_7.impl_set_information('source', "file")
+option_11 = FilenameOption(name="name", doc="name", default="/etc/file2")
+option_12 = BoolOption(name="activate", doc="activate", default=True)
+option_10 = OptionDescription(name="file2", doc="file2", children=[option_11, option_12])
+option_10.impl_set_information('engine', "jinja2")
+option_10.impl_set_information('source', "file2")
+option_14 = FilenameOption(name="name", doc="name", default="/etc/file3")
+option_15 = BoolOption(name="activate", doc="activate", default=False)
+option_13 = OptionDescription(name="file3", doc="file3", children=[option_14, option_15])
+option_13.impl_set_information('source', "file3")
+option_6 = OptionDescription(name="files", doc="files", children=[option_7, option_10, option_13])
+option_16 = BoolOption(name="activate", doc="activate", default=True)
+option_17 = BoolOption(name="manage", doc="manage", default=True)
+option_5 = OptionDescription(name="test", doc="test", children=[option_6, option_16, option_17])
+option_4 = OptionDescription(name="services", doc="services", children=[option_5], properties=frozenset({"hidden"}))
+option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_4])
diff --git a/tests/dictionaries/01base_file_disabled/tmpl/file b/tests/dictionaries/01base_file_disabled/tmpl/file
new file mode 100644
index 000000000..27ff6834c
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/tmpl/file
@@ -0,0 +1,2 @@
+%%mode_conteneur_actif
+%%rougail.general.mode_conteneur_actif
diff --git a/tests/dictionaries/01base_file_disabled/tmpl/file2 b/tests/dictionaries/01base_file_disabled/tmpl/file2
new file mode 100644
index 000000000..6d214113d
--- /dev/null
+++ b/tests/dictionaries/01base_file_disabled/tmpl/file2
@@ -0,0 +1,2 @@
+{{ mode_conteneur_actif }}
+{{ rougail.general.mode_conteneur_actif }}