add index function in leader

This commit is contained in:
Emmanuel Garette 2022-05-22 19:17:35 +02:00
parent 366ab9918b
commit ea8bc3f02e
5 changed files with 9 additions and 0 deletions

View file

@ -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,

View file

@ -9,3 +9,4 @@ testpre
pretest
leader2: test
follower2: pre
index: 0

View file

@ -9,3 +9,4 @@ testpre
pretest
leader2: test
follower2: pre
index: 0

View file

@ -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')

View file

@ -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') }}