Compare commits
No commits in common. "2e0e17705be0bfaa3ee46c055414c7c133b5ac86" and "5b4b43d5f492734b646dafb6d40e27c151813b3a" have entirely different histories.
2e0e17705b
...
5b4b43d5f4
|
@ -75,7 +75,6 @@ KEY_TYPE = {'variable': 'symlink',
|
||||||
TYPE_PARAM_CHECK = ('string', 'python', 'eole', 'variable')
|
TYPE_PARAM_CHECK = ('string', 'python', 'eole', 'variable')
|
||||||
TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'eole', 'variable')
|
TYPE_PARAM_CONDITION = ('string', 'python', 'number', 'eole', 'variable')
|
||||||
TYPE_PARAM_FILL = ('string', 'eole', 'number', 'context', 'variable')
|
TYPE_PARAM_FILL = ('string', 'eole', 'number', 'context', 'variable')
|
||||||
CONVERSION = {'number': int}
|
|
||||||
|
|
||||||
ERASED_FAMILY_ACTION_ATTRIBUTES = ('index', 'action')
|
ERASED_FAMILY_ACTION_ATTRIBUTES = ('index', 'action')
|
||||||
|
|
||||||
|
@ -686,13 +685,7 @@ class SpaceAnnotator(object):
|
||||||
choices = []
|
choices = []
|
||||||
for value in values:
|
for value in values:
|
||||||
choice = self.objectspace.choice()
|
choice = self.objectspace.choice()
|
||||||
try:
|
|
||||||
if type_ in CONVERSION:
|
|
||||||
choice.name = CONVERSION[type_](value)
|
|
||||||
else:
|
|
||||||
choice.name = str(value)
|
choice.name = str(value)
|
||||||
except:
|
|
||||||
raise CreoleDictConsistencyError(_(f'unable to change type of a valid_enum entry "{value}" is not a valid "{type_}" for "{variable.name}"'))
|
|
||||||
choices.append(choice.name)
|
choices.append(choice.name)
|
||||||
choice.type = type_
|
choice.type = type_
|
||||||
variable.choice.append(choice)
|
variable.choice.append(choice)
|
||||||
|
@ -701,11 +694,7 @@ class SpaceAnnotator(object):
|
||||||
if hasattr(variable, 'value'):
|
if hasattr(variable, 'value'):
|
||||||
for value in variable.value:
|
for value in variable.value:
|
||||||
value.type = type_
|
value.type = type_
|
||||||
if type_ in CONVERSION:
|
if value.name not in choices:
|
||||||
cvalue = CONVERSION[type_](value.name)
|
|
||||||
else:
|
|
||||||
cvalue = value.name
|
|
||||||
if cvalue not in choices:
|
|
||||||
raise CreoleDictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
|
raise CreoleDictConsistencyError(_('value "{}" of variable "{}" is not in list of all expected values ({})').format(value.name, variable.name, choices))
|
||||||
else:
|
else:
|
||||||
new_value = self.objectspace.value()
|
new_value = self.objectspace.value()
|
||||||
|
|
|
@ -44,8 +44,8 @@ mo_location = LOCALE_DIR
|
||||||
|
|
||||||
gettext.find(APP_NAME, mo_location)
|
gettext.find(APP_NAME, mo_location)
|
||||||
gettext.textdomain(APP_NAME)
|
gettext.textdomain(APP_NAME)
|
||||||
#gettext.bind_textdomain_codeset(APP_NAME, "UTF-8")
|
gettext.bind_textdomain_codeset(APP_NAME, "UTF-8")
|
||||||
#gettext.translation(APP_NAME, fallback=True)
|
gettext.translation(APP_NAME, fallback=True)
|
||||||
|
|
||||||
t = gettext.translation(APP_NAME, fallback=True)
|
t = gettext.translation(APP_NAME, fallback=True)
|
||||||
|
|
||||||
|
|
|
@ -262,17 +262,13 @@ class CreoleTemplateEngine:
|
||||||
distrib_dir: str,
|
distrib_dir: str,
|
||||||
tmp_dir: str,
|
tmp_dir: str,
|
||||||
dest_dir: str,
|
dest_dir: str,
|
||||||
override_dest_dir: str,
|
|
||||||
tmpfile_name: str,
|
tmpfile_name: str,
|
||||||
factory_prefix: str,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
self.config = config
|
self.config = config
|
||||||
self.dest_dir = dest_dir
|
self.dest_dir = dest_dir
|
||||||
self.override_dest_dir = override_dest_dir
|
|
||||||
self.tmp_dir = tmp_dir
|
self.tmp_dir = tmp_dir
|
||||||
self.distrib_dir = distrib_dir
|
self.distrib_dir = distrib_dir
|
||||||
self.tmpfile_name = tmpfile_name
|
self.tmpfile_name = tmpfile_name
|
||||||
self.factory_prefix = factory_prefix
|
|
||||||
eos = {}
|
eos = {}
|
||||||
if eosfunc_file is not None:
|
if eosfunc_file is not None:
|
||||||
eosfunc = imp.load_source('eosfunc', eosfunc_file)
|
eosfunc = imp.load_source('eosfunc', eosfunc_file)
|
||||||
|
@ -386,7 +382,7 @@ class CreoleTemplateEngine:
|
||||||
else:
|
else:
|
||||||
variable = None
|
variable = None
|
||||||
if override:
|
if override:
|
||||||
filenames = [f'/systemd/system/{service_name}.service.d/rougail.conf']
|
filenames = [f'/system/{service_name}.service.d/rougail.conf']
|
||||||
else:
|
else:
|
||||||
filenames = filevar['name']
|
filenames = filevar['name']
|
||||||
if not isinstance(filenames, list):
|
if not isinstance(filenames, list):
|
||||||
|
@ -394,10 +390,8 @@ class CreoleTemplateEngine:
|
||||||
if variable:
|
if variable:
|
||||||
variable = [variable]
|
variable = [variable]
|
||||||
for idx, filename in enumerate(filenames):
|
for idx, filename in enumerate(filenames):
|
||||||
if override:
|
destfilename = join(self.dest_dir,
|
||||||
destfilename = join(self.override_dest_dir, filename[1:])
|
filename[1:])
|
||||||
else:
|
|
||||||
destfilename = join(self.dest_dir, filename[1:])
|
|
||||||
makedirs(dirname(destfilename), exist_ok=True)
|
makedirs(dirname(destfilename), exist_ok=True)
|
||||||
if variable:
|
if variable:
|
||||||
var = variable[idx]
|
var = variable[idx]
|
||||||
|
@ -412,7 +406,7 @@ class CreoleTemplateEngine:
|
||||||
else:
|
else:
|
||||||
copy(source, destfilename)
|
copy(source, destfilename)
|
||||||
if not override and self.tmpfile_name:
|
if not override and self.tmpfile_name:
|
||||||
systemd_rights.append(f'C {filename} {filevar["mode"]} {filevar["owner"]} {filevar["group"]} - {self.factory_prefix}{filename}')
|
systemd_rights.append(f'C {filename} {filevar["mode"]} {filevar["owner"]} {filevar["group"]} - -')
|
||||||
systemd_rights.append(f'z {filename} - - - - -')
|
systemd_rights.append(f'z {filename} - - - - -')
|
||||||
|
|
||||||
async def instance_files(self) -> None:
|
async def instance_files(self) -> None:
|
||||||
|
@ -461,22 +455,11 @@ async def generate(config: Config,
|
||||||
distrib_dir: str,
|
distrib_dir: str,
|
||||||
tmp_dir: str,
|
tmp_dir: str,
|
||||||
dest_dir: str,
|
dest_dir: str,
|
||||||
override_dest_dir: str,
|
tmpfile_name: str=None) -> None:
|
||||||
tmpfile_name: str=None,
|
|
||||||
factory_prefix: str=None,
|
|
||||||
) -> None:
|
|
||||||
if not tmpfile_name and factory_prefix:
|
|
||||||
raise Exception(_(f'only specify factory_prefix if tmpfile_name is set'))
|
|
||||||
if tmpfile_name and not factory_prefix:
|
|
||||||
raise Exception(_(f'if tmpfile_name is specify, set factory_prefix too'))
|
|
||||||
|
|
||||||
engine = CreoleTemplateEngine(config,
|
engine = CreoleTemplateEngine(config,
|
||||||
eosfunc_file,
|
eosfunc_file,
|
||||||
distrib_dir,
|
distrib_dir,
|
||||||
tmp_dir,
|
tmp_dir,
|
||||||
dest_dir,
|
dest_dir,
|
||||||
override_dest_dir,
|
tmpfile_name)
|
||||||
tmpfile_name,
|
|
||||||
factory_prefix,
|
|
||||||
)
|
|
||||||
await engine.instance_files()
|
await engine.instance_files()
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
<constraints>
|
<constraints>
|
||||||
<check name="valid_enum" target="enumvar">
|
<check name="valid_enum" target="enumvar">
|
||||||
<param>['a', 'b', 'c']</param>
|
<param>[i for i in range(3, 13)]</param>
|
||||||
</check>
|
</check>
|
||||||
</constraints>
|
</constraints>
|
||||||
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<rougail>
|
|
||||||
|
|
||||||
<services/>
|
|
||||||
|
|
||||||
<variables>
|
|
||||||
<family name="general" mode="expert">
|
|
||||||
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
|
|
||||||
<value>non</value>
|
|
||||||
</variable>
|
|
||||||
</family>
|
|
||||||
<family name="enumfam" mode="expert">
|
|
||||||
<variable name="enumvar" type="string" description="enumvar">
|
|
||||||
<value>a</value>
|
|
||||||
</variable>
|
|
||||||
</family>
|
|
||||||
<separators/>
|
|
||||||
</variables>
|
|
||||||
|
|
||||||
<constraints>
|
|
||||||
<check name="valid_enum" target="enumvar">
|
|
||||||
<param>[1, 2, 3]</param>
|
|
||||||
</check>
|
|
||||||
</constraints>
|
|
||||||
|
|
||||||
<help>
|
|
||||||
<variable name="enumvar">bla bla bla</variable>
|
|
||||||
</help>
|
|
||||||
|
|
||||||
</rougail>
|
|
||||||
<!-- vim: ts=4 sw=4 expandtab
|
|
||||||
-->
|
|
|
@ -83,7 +83,7 @@ def launch_flattener(test_dir, test_ok=False):
|
||||||
eolobj.save(destfile)
|
eolobj.save(destfile)
|
||||||
result_file = join(test_dir, 'result/00-base.xml')
|
result_file = join(test_dir, 'result/00-base.xml')
|
||||||
if isfile(result_file):
|
if isfile(result_file):
|
||||||
#eolobj.save(result_file)
|
eolobj.save(result_file)
|
||||||
compare_xml(destfile, result_file)
|
compare_xml(destfile, result_file)
|
||||||
elif test_ok:
|
elif test_ok:
|
||||||
raise Exception(f'no test found for {test_dir}')
|
raise Exception(f'no test found for {test_dir}')
|
||||||
|
|
Loading…
Reference in New Issue