allow any character as service name

This commit is contained in:
Emmanuel Garette 2021-05-14 07:00:55 +02:00
parent 9c1589ca53
commit 4711206c55
12 changed files with 78 additions and 13 deletions

View File

@ -28,7 +28,7 @@ from os.path import basename
from typing import Tuple
from rougail.i18n import _
from rougail.utils import normalize_family, valid_variable_family_name
from rougail.utils import normalize_family
from rougail.error import DictConsistencyError
# a object's attribute has some annotations
# that shall not be present in the exported (flatened) XML
@ -70,14 +70,14 @@ class Annotator:
self.objectspace.space.services.doc = 'services'
self.objectspace.space.services.path = 'services'
for service_name, service in self.objectspace.space.services.service.items():
valid_variable_family_name(service_name, service.xmlfiles)
service.name = normalize_family(service_name)
activate_obj = self._generate_element('boolean',
None,
None,
'activate',
not service.disabled,
service,
'.'.join(['services', normalize_family(service_name), 'activate']),
'.'.join(['services', service.name, 'activate']),
)
service.disabled = None
for elttype, values in dict(vars(service)).items():
@ -97,7 +97,7 @@ class Annotator:
eltname = elttype + 's'
else:
eltname = elttype
path = '.'.join(['services', normalize_family(service_name), eltname])
path = '.'.join(['services', service.name, eltname])
family = self._gen_family(eltname,
path,
service.xmlfiles,
@ -121,10 +121,10 @@ class Annotator:
'manage',
service.manage,
service,
'.'.join(['services', normalize_family(service_name), 'manage']),
'.'.join(['services', service.name, 'manage']),
)
service.variable = [activate_obj, manage]
service.doc = service.name
service.doc = service_name
def make_group_from_elts(self,
service_name,

View File

@ -320,7 +320,7 @@ class RougailBaseTemplate:
self.prepare_template(template)
for included in (True, False):
for service_obj in await self.config.option('services').list('all'):
service_name = await service_obj.option.name()
service_name = await service_obj.option.description()
service_type = await service_obj.information.get('type', 'service')
if await service_obj.option('activate').value.get() is False:
if included is False:

View File

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<services>
<service name="test-srv" engine="creole">
</service>
</services>
<variables>
<family name="general" description="général">
<variable name="mode_conteneur_actif" type="string" description="No change" hidden="True">
<value>oui</value>
</variable>
</family>
</variables>
</rougail>

View File

@ -0,0 +1,14 @@
{
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": "oui"
},
"services.test_srv.activate": {
"owner": "default",
"value": true
},
"services.test_srv.manage": {
"owner": "default",
"value": true
}
}

View File

@ -0,0 +1,5 @@
{
"rougail.general.mode_conteneur_actif": "oui",
"services.test_srv.activate": true,
"services.test_srv.manage": true
}

View File

@ -0,0 +1,14 @@
{
"rougail.general.mode_conteneur_actif": {
"owner": "default",
"value": "oui"
},
"services.test_srv.activate": {
"owner": "default",
"value": true
},
"services.test_srv.manage": {
"owner": "default",
"value": true
}
}

View File

@ -0,0 +1,22 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
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 key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
option_3 = StrOption(name="mode_conteneur_actif", doc="No change", default="oui", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "mandatory", "normal"}))
option_2 = OptionDescription(name="general", doc="général", children=[option_3], properties=frozenset({"normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_6 = BoolOption(name="activate", doc="activate", default=True)
option_7 = BoolOption(name="manage", doc="manage", default=True)
option_5 = OptionDescription(name="test_srv", doc="test-srv", children=[option_6, option_7])
option_5.impl_set_information('engine', "creole")
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])

View File

@ -0,0 +1 @@
%%mode_conteneur_actif

View File

@ -1,6 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<services>
<service name="testsrv.mount"/>
</services>
</rougail>