diff --git a/src/rougail/template/base.py b/src/rougail/template/base.py index a7269c3b5..5d18cfab6 100644 --- a/src/rougail/template/base.py +++ b/src/rougail/template/base.py @@ -169,6 +169,9 @@ class RougailLeader: value = err self._follower[name].append(value) + def index(self, value): + return self._value.index(value) + class RougailExtra: """Object that implement access to extra variable @@ -310,6 +313,8 @@ class RougailBaseTemplate: destfilename = join(self.destinations_dir, true_destfilename[1:]) makedirs(dirname(destfilename), exist_ok=True) self.log.info(_(f"{filevar['engine']} processing: '{destfilename}'")) + if isfile(destfilename): + raise TemplateError(_(f'destination file "{destfilename}" already exists')) self.engines[filevar['engine']].process(filename=filename, source=source, true_destfilename=true_destfilename, diff --git a/tests/dictionaries/60extra_leadership_name/result/etc/mailname b/tests/dictionaries/60extra_leadership_name/result/etc/mailname index dc34cc5b0..a3fa3a51e 100644 --- a/tests/dictionaries/60extra_leadership_name/result/etc/mailname +++ b/tests/dictionaries/60extra_leadership_name/result/etc/mailname @@ -9,3 +9,4 @@ testpre pretest leader2: test follower2: pre +index: 0 diff --git a/tests/dictionaries/60extra_leadership_name/result/etc/mailname2 b/tests/dictionaries/60extra_leadership_name/result/etc/mailname2 index dc34cc5b0..a3fa3a51e 100644 --- a/tests/dictionaries/60extra_leadership_name/result/etc/mailname2 +++ b/tests/dictionaries/60extra_leadership_name/result/etc/mailname2 @@ -9,3 +9,4 @@ testpre pretest leader2: test follower2: pre +index: 0 diff --git a/tests/dictionaries/60extra_leadership_name/tmpl/mailname b/tests/dictionaries/60extra_leadership_name/tmpl/mailname index 92eeafc40..3fc4092ec 100644 --- a/tests/dictionaries/60extra_leadership_name/tmpl/mailname +++ b/tests/dictionaries/60extra_leadership_name/tmpl/mailname @@ -33,3 +33,4 @@ diff %end for leader2: %%extra.ejabberd.new_name.description[0].description follower2: %%extra.ejabberd.new_name.description[0].mode +index: %%extra.ejabberd.new_name.description.index('test') diff --git a/tests/dictionaries/60extra_leadership_name/tmpl/mailname2 b/tests/dictionaries/60extra_leadership_name/tmpl/mailname2 index 0823099e8..0925d8b7a 100644 --- a/tests/dictionaries/60extra_leadership_name/tmpl/mailname2 +++ b/tests/dictionaries/60extra_leadership_name/tmpl/mailname2 @@ -31,3 +31,4 @@ diff {% endfor -%} leader2: {{ extra.ejabberd.new_name.description[0].description }} follower2: {{ extra.ejabberd.new_name.description[0].mode }} +index: {{ extra.ejabberd.new_name.description.index('test') }}