one unique source could create 2 templates
This commit is contained in:
parent
00a69e72a2
commit
b612d7884e
11 changed files with 103 additions and 20 deletions
|
@ -265,15 +265,17 @@ class ServiceAnnotator:
|
|||
name,
|
||||
path,
|
||||
):
|
||||
family = self.objectspace.family()
|
||||
family.name = normalize_family(name)
|
||||
family.doc = name
|
||||
family.mode = None
|
||||
self.objectspace.paths.add_family('services',
|
||||
path,
|
||||
family,
|
||||
)
|
||||
return family
|
||||
if self.objectspace.paths.family_is_defined(path):
|
||||
return self.objectspace.paths.get_family_obj(path)
|
||||
family = self.objectspace.family()
|
||||
family.name = normalize_family(name)
|
||||
family.doc = name
|
||||
family.mode = None
|
||||
self.objectspace.paths.add_family('services',
|
||||
path,
|
||||
family,
|
||||
)
|
||||
return family
|
||||
|
||||
def make_group_from_elts(self,
|
||||
service_name,
|
||||
|
@ -301,11 +303,18 @@ class ServiceAnnotator:
|
|||
service_name,
|
||||
)
|
||||
|
||||
if hasattr(elt, 'source'):
|
||||
c_name = elt.source
|
||||
else:
|
||||
c_name = elt.name
|
||||
subpath = '{}.{}'.format(path, c_name)
|
||||
idx = 0
|
||||
while True:
|
||||
if hasattr(elt, 'source'):
|
||||
c_name = elt.source
|
||||
else:
|
||||
c_name = elt.name
|
||||
if idx:
|
||||
c_name += f'_{idx}'
|
||||
subpath = '{}.{}'.format(path, c_name)
|
||||
if not self.objectspace.paths.family_is_defined(subpath):
|
||||
break
|
||||
idx += 1
|
||||
family = self.gen_family(c_name, subpath)
|
||||
family.variable = []
|
||||
listname = '{}list'.format(name)
|
||||
|
|
|
@ -522,7 +522,6 @@ class CreoleObjSpace:
|
|||
SpaceAnnotator(self, eosfunc_file)
|
||||
|
||||
def save(self,
|
||||
filename,
|
||||
):
|
||||
tiramisu_objects = TiramisuReflector(self.space,
|
||||
self.funcs_path,
|
||||
|
|
|
@ -26,6 +26,8 @@ class Path:
|
|||
self.full_paths[name] = full_name
|
||||
else:
|
||||
full_name = name
|
||||
if full_name in self.families and self.families[full_name]['variableobj'] != variableobj:
|
||||
raise DictConsistencyError(_(f'Duplicate family name {name}'))
|
||||
self.families[full_name] = dict(name=name,
|
||||
namespace=namespace,
|
||||
variableobj=variableobj,
|
||||
|
@ -60,6 +62,13 @@ class Path:
|
|||
dico = self.families[name]
|
||||
return dico['variableobj']
|
||||
|
||||
def family_is_defined(self,
|
||||
name: str,
|
||||
) -> str: # pylint: disable=C0111
|
||||
if '.' not in name and name not in self.families and name in self.full_paths:
|
||||
return True
|
||||
return name in self.families
|
||||
|
||||
# Leadership
|
||||
def set_leader(self,
|
||||
namespace: str,
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.activer_ejabberd": "non", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.templating": true, "services.test.files.mailname.activate": true, "extra.ejabberd.description.description": ["test"], "extra.ejabberd.description.mode": ["pre"]}
|
||||
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.activer_ejabberd": "non", "extra.ejabberd.description.description": ["test"], "extra.ejabberd.description.mode": ["pre"], "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.templating": true, "services.test.files.mailname.activate": true}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.activer_ejabberd": "non", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.templating": true, "services.test.files.mailname.activate": true, "extra.ejabberd.description": "Exportation de la base de ejabberd", "extra.ejabberd.day": null, "extra.ejabberd.mode": "pre"}
|
||||
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.activer_ejabberd": "non", "extra.ejabberd.description": "Exportation de la base de ejabberd", "extra.ejabberd.day": null, "extra.ejabberd.mode": "pre", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.templating": true, "services.test.files.mailname.activate": true}
|
||||
|
|
30
tests/flattener_dicos/70container_files_twice/00-base.xml
Normal file
30
tests/flattener_dicos/70container_files_twice/00-base.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<rougail>
|
||||
|
||||
<services>
|
||||
<service name='test'>
|
||||
<file name='/etc/mailname'/>
|
||||
<file name='/etc/eole/mailname'/>
|
||||
<file name='/rougail.conf'/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
|
||||
<variables>
|
||||
<family name='général'>
|
||||
<variable name='mode_conteneur_actif' type='oui/non' description="No change" hidden="True">
|
||||
<value>oui</value>
|
||||
</variable>
|
||||
</family>
|
||||
<separators/>
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
</constraints>
|
||||
|
||||
<help/>
|
||||
|
||||
</rougail>
|
||||
<!-- vim: ts=4 sw=4 expandtab
|
||||
-->
|
|
@ -0,0 +1 @@
|
|||
{"rougail.general.mode_conteneur_actif": "oui", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.templating": true, "services.test.files.mailname.activate": true, "services.test.files.mailname_1.group": "root", "services.test.files.mailname_1.mode": "0644", "services.test.files.mailname_1.name": "/etc/eole/mailname", "services.test.files.mailname_1.owner": "root", "services.test.files.mailname_1.source": "mailname", "services.test.files.mailname_1.templating": true, "services.test.files.mailname_1.activate": true, "services.test.files.rougail_conf.group": "root", "services.test.files.rougail_conf.mode": "0644", "services.test.files.rougail_conf.name": "/rougail.conf", "services.test.files.rougail_conf.owner": "root", "services.test.files.rougail_conf.source": "rougail.conf", "services.test.files.rougail_conf.templating": true, "services.test.files.rougail_conf.activate": true}
|
|
@ -0,0 +1,36 @@
|
|||
from tiramisu import *
|
||||
from rougail.tiramisu import ConvertDynOptionDescription
|
||||
import imp
|
||||
func = imp.load_source('func', 'tests/flattener_dicos/../eosfunc/test.py')
|
||||
option_3 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='oui', values=('oui', 'non'))
|
||||
option_2 = OptionDescription(name='general', doc='général', properties=frozenset({'normal'}), children=[option_3])
|
||||
option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2])
|
||||
option_8 = StrOption(name='group', doc='group', multi=False, default='root')
|
||||
option_9 = StrOption(name='mode', doc='mode', multi=False, default='0644')
|
||||
option_10 = StrOption(name='name', doc='name', multi=False, default='/etc/mailname')
|
||||
option_11 = StrOption(name='owner', doc='owner', multi=False, default='root')
|
||||
option_12 = StrOption(name='source', doc='source', multi=False, default='mailname')
|
||||
option_13 = BoolOption(name='templating', doc='templating', multi=False, default=True)
|
||||
option_14 = BoolOption(name='activate', doc='activate', multi=False, default=True)
|
||||
option_7 = OptionDescription(name='mailname', doc='mailname', children=[option_8, option_9, option_10, option_11, option_12, option_13, option_14])
|
||||
option_16 = StrOption(name='group', doc='group', multi=False, default='root')
|
||||
option_17 = StrOption(name='mode', doc='mode', multi=False, default='0644')
|
||||
option_18 = StrOption(name='name', doc='name', multi=False, default='/etc/eole/mailname')
|
||||
option_19 = StrOption(name='owner', doc='owner', multi=False, default='root')
|
||||
option_20 = StrOption(name='source', doc='source', multi=False, default='mailname')
|
||||
option_21 = BoolOption(name='templating', doc='templating', multi=False, default=True)
|
||||
option_22 = BoolOption(name='activate', doc='activate', multi=False, default=True)
|
||||
option_15 = OptionDescription(name='mailname_1', doc='mailname_1', children=[option_16, option_17, option_18, option_19, option_20, option_21, option_22])
|
||||
option_24 = StrOption(name='group', doc='group', multi=False, default='root')
|
||||
option_25 = StrOption(name='mode', doc='mode', multi=False, default='0644')
|
||||
option_26 = StrOption(name='name', doc='name', multi=False, default='/rougail.conf')
|
||||
option_27 = StrOption(name='owner', doc='owner', multi=False, default='root')
|
||||
option_28 = StrOption(name='source', doc='source', multi=False, default='rougail.conf')
|
||||
option_29 = BoolOption(name='templating', doc='templating', multi=False, default=True)
|
||||
option_30 = BoolOption(name='activate', doc='activate', multi=False, default=True)
|
||||
option_23 = OptionDescription(name='rougail_conf', doc='rougail.conf', children=[option_24, option_25, option_26, option_27, option_28, option_29, option_30])
|
||||
option_6 = OptionDescription(name='files', doc='files', children=[option_7, option_15, option_23])
|
||||
option_5 = OptionDescription(name='test', doc='test', children=[option_6])
|
||||
option_5.impl_set_information("manage", True)
|
||||
option_4 = OptionDescription(name='services', doc='services', properties=frozenset({'hidden'}), children=[option_5])
|
||||
option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1, option_4])
|
|
@ -11,7 +11,6 @@ from rougail.config import dtdfilename, variable_namespace
|
|||
|
||||
|
||||
|
||||
destfile = '/tmp/test.xml'
|
||||
dico_dirs = 'tests/flattener_dicos'
|
||||
|
||||
|
||||
|
@ -28,7 +27,7 @@ for test in listdir(dico_dirs):
|
|||
excludes = set([])
|
||||
test_ok -= excludes
|
||||
test_raise -= excludes
|
||||
#test_ok = ['11multi_disabled_if_in_filelist']
|
||||
#test_ok = ['10leadership_autoleader']
|
||||
#test_raise = []
|
||||
|
||||
|
||||
|
@ -82,7 +81,7 @@ def launch_flattener(test_dir, test_ok=False):
|
|||
eolobj.create_or_populate_from_xml('extra1', [subfolder])
|
||||
eosfunc = join(dico_dirs, '../eosfunc/test.py')
|
||||
eolobj.space_visitor(eosfunc)
|
||||
tiramisu_objects = eolobj.save(destfile)
|
||||
tiramisu_objects = eolobj.save()
|
||||
tiramisu_dir = join(test_dir, 'tiramisu')
|
||||
tiramisu_file = join(tiramisu_dir, 'base.py')
|
||||
if not isfile(tiramisu_file) or debug:
|
||||
|
|
Loading…
Reference in a new issue