add remove fill without fill test + patches_dir is multi
This commit is contained in:
parent
3c5d4a4fa6
commit
f91132fc61
7 changed files with 148 additions and 87 deletions
|
@ -62,7 +62,7 @@ log.addHandler(logging.NullHandler())
|
||||||
|
|
||||||
INFORMATIONS = {'files': ['source', 'mode', 'engine', 'included'],
|
INFORMATIONS = {'files': ['source', 'mode', 'engine', 'included'],
|
||||||
'overrides': ['name', 'source', 'engine'],
|
'overrides': ['name', 'source', 'engine'],
|
||||||
'service_names': ['doc', 'engine', 'type'],
|
'service_names': ['doc', 'engine', 'type', 'target', 'undisable'],
|
||||||
}
|
}
|
||||||
DEFAULT = {'files': ['owner', 'group'],
|
DEFAULT = {'files': ['owner', 'group'],
|
||||||
'overrides': [],
|
'overrides': [],
|
||||||
|
@ -178,6 +178,10 @@ class RougailLeader:
|
||||||
def index(self, value):
|
def index(self, value):
|
||||||
return self._value.index(value)
|
return self._value.index(value)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
followers_name = list(self._follower)
|
||||||
|
return f'RougailLeader({followers_name[0]}) => {followers_name[1:]}'
|
||||||
|
|
||||||
|
|
||||||
class RougailExtra:
|
class RougailExtra:
|
||||||
"""Object that implement access to extra variable
|
"""Object that implement access to extra variable
|
||||||
|
@ -212,7 +216,7 @@ class RougailExtra:
|
||||||
return self._suboption.items()
|
return self._suboption.items()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self._name
|
return f'RougailExtra("{self._name}") => {self._suboption}'
|
||||||
|
|
||||||
|
|
||||||
class RougailBaseTemplate:
|
class RougailBaseTemplate:
|
||||||
|
@ -233,7 +237,12 @@ class RougailBaseTemplate:
|
||||||
templates_dir = [templates_dir]
|
templates_dir = [templates_dir]
|
||||||
for templ_dir in templates_dir:
|
for templ_dir in templates_dir:
|
||||||
self.templates_dir.append(abspath(templ_dir))
|
self.templates_dir.append(abspath(templ_dir))
|
||||||
self.patches_dir = abspath(rougailconfig['patches_dir'])
|
patches_dir = rougailconfig['patches_dir']
|
||||||
|
if not isinstance(patches_dir, list):
|
||||||
|
patches_dir = [patches_dir]
|
||||||
|
self.patches_dir = []
|
||||||
|
for p_dir in patches_dir:
|
||||||
|
self.patches_dir.append(abspath(p_dir))
|
||||||
eos = {}
|
eos = {}
|
||||||
functions_file = rougailconfig['functions_file']
|
functions_file = rougailconfig['functions_file']
|
||||||
if not isinstance(functions_file, list):
|
if not isinstance(functions_file, list):
|
||||||
|
@ -259,7 +268,8 @@ class RougailBaseTemplate:
|
||||||
patch_cmd = ['patch', '-d', self.tmp_dir, '-N', '-p1', '-f']
|
patch_cmd = ['patch', '-d', self.tmp_dir, '-N', '-p1', '-f']
|
||||||
patch_no_debug = ['-s', '-r', '-', '--backup-if-mismatch']
|
patch_no_debug = ['-s', '-r', '-', '--backup-if-mismatch']
|
||||||
|
|
||||||
patch_file = join(self.patches_dir, f'{filename}.patch')
|
for patches_dir in self.patches_dir:
|
||||||
|
patch_file = join(patches_dir, f'{filename}.patch')
|
||||||
if isfile(patch_file):
|
if isfile(patch_file):
|
||||||
self.log.info(_("Patching template '{filename}' with '{patch_file}'"))
|
self.log.info(_("Patching template '{filename}' with '{patch_file}'"))
|
||||||
ret = call(patch_cmd + patch_no_debug + ['-i', patch_file])
|
ret = call(patch_cmd + patch_no_debug + ['-i', patch_file])
|
||||||
|
@ -362,6 +372,7 @@ class RougailBaseTemplate:
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
ori_dir = None
|
ori_dir = None
|
||||||
chdir(self.tmp_dir)
|
chdir(self.tmp_dir)
|
||||||
|
try:
|
||||||
if not self.rougail_variables_dict:
|
if not self.rougail_variables_dict:
|
||||||
await self.load_variables()
|
await self.load_variables()
|
||||||
for templates_dir in self.templates_dir:
|
for templates_dir in self.templates_dir:
|
||||||
|
@ -421,6 +432,10 @@ class RougailBaseTemplate:
|
||||||
break
|
break
|
||||||
rmdir(parent)
|
rmdir(parent)
|
||||||
self.post_instance()
|
self.post_instance()
|
||||||
|
except Exception as err:
|
||||||
|
if ori_dir is not None:
|
||||||
|
chdir(ori_dir)
|
||||||
|
raise err
|
||||||
if ori_dir is not None:
|
if ori_dir is not None:
|
||||||
chdir(ori_dir)
|
chdir(ori_dir)
|
||||||
|
|
||||||
|
@ -443,11 +458,20 @@ class RougailBaseTemplate:
|
||||||
obj: 'Option',
|
obj: 'Option',
|
||||||
) -> None:
|
) -> None:
|
||||||
for key in INFORMATIONS.get(type_, []):
|
for key in INFORMATIONS.get(type_, []):
|
||||||
|
if key == 'target':
|
||||||
|
default_value = None
|
||||||
|
elif key == 'undisable':
|
||||||
|
default_value = False
|
||||||
|
elif key == 'engine' and type_ == 'service_names':
|
||||||
|
default_value = None
|
||||||
|
else:
|
||||||
default_key = f'default_{type_}_{key}'
|
default_key = f'default_{type_}_{key}'
|
||||||
if default_key in RougailConfig:
|
if default_key in RougailConfig:
|
||||||
default_value = RougailConfig[default_key]
|
default_value = RougailConfig[default_key]
|
||||||
else:
|
else:
|
||||||
default_value = undefined
|
default_value = undefined
|
||||||
|
value = await obj.information.get(key, default_value)
|
||||||
|
if key not in ['target', 'undisable'] or value != default_value:
|
||||||
dico[key] = await obj.information.get(key, default_value)
|
dico[key] = await obj.information.get(key, default_value)
|
||||||
|
|
||||||
def desactive_service(self,
|
def desactive_service(self,
|
||||||
|
@ -547,7 +571,7 @@ class RougailBaseTemplate:
|
||||||
await suboption.option.name(),
|
await suboption.option.name(),
|
||||||
path,
|
path,
|
||||||
)
|
)
|
||||||
variables[leadership_name] = RougailExtra(await optiondescription.option.name(), {leader_name: leader}, await optiondescription.option.path())
|
variables[leadership_name] = RougailExtra(await option.option.name(), {leader_name: leader}, await option.option.path())
|
||||||
else:
|
else:
|
||||||
if is_service_namespace == 'root':
|
if is_service_namespace == 'root':
|
||||||
new_is_service_namespace = 'service_name'
|
new_is_service_namespace = 'service_name'
|
||||||
|
@ -567,15 +591,6 @@ class RougailBaseTemplate:
|
||||||
if is_variable_namespace:
|
if is_variable_namespace:
|
||||||
value = await option.value.get()
|
value = await option.value.get()
|
||||||
self.rougail_variables_dict[await option.option.name()] = value
|
self.rougail_variables_dict[await option.option.name()] = value
|
||||||
if await option.option.issymlinkoption() and await option.option.isfollower():
|
|
||||||
value = []
|
|
||||||
if isinstance(self.config, TiramisuOption):
|
|
||||||
path = (await option.option.path())[len_root_path:]
|
|
||||||
else:
|
|
||||||
path = await option.option.path()
|
|
||||||
for index in range(await option.value.len()):
|
|
||||||
value.append(await self.config.option(path, index).value.get())
|
|
||||||
else:
|
|
||||||
value = await option.value.get()
|
value = await option.value.get()
|
||||||
variables[await option.option.name()] = value
|
variables[await option.option.name()] = value
|
||||||
if isinstance(is_service_namespace, str) and is_service_namespace + 's' in INFORMATIONS:
|
if isinstance(is_service_namespace, str) and is_service_namespace + 's' in INFORMATIONS:
|
||||||
|
|
0
tests/dictionaries/80remove_fill_no_fill/__init__.py
Normal file
0
tests/dictionaries/80remove_fill_no_fill/__init__.py
Normal file
0
tests/dictionaries/80remove_fill_no_fill/errno_89
Normal file
0
tests/dictionaries/80remove_fill_no_fill/errno_89
Normal file
13
tests/dictionaries/80remove_fill_no_fill/xml/00-base.xml
Normal file
13
tests/dictionaries/80remove_fill_no_fill/xml/00-base.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<rougail version="0.10">
|
||||||
|
<variables>
|
||||||
|
<family name="general">
|
||||||
|
<variable name="mode_conteneur_actif" type="string" description="No change">
|
||||||
|
<value>oui</value>
|
||||||
|
</variable>
|
||||||
|
<variable name="mode_conteneur_actif1" type="string" description="No change">
|
||||||
|
<value>non</value>
|
||||||
|
</variable>
|
||||||
|
</family>
|
||||||
|
</variables>
|
||||||
|
</rougail>
|
8
tests/dictionaries/80remove_fill_no_fill/xml/01-base.xml
Normal file
8
tests/dictionaries/80remove_fill_no_fill/xml/01-base.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<rougail version="0.10">
|
||||||
|
<variables>
|
||||||
|
<family name="general">
|
||||||
|
<variable name="mode_conteneur_actif" redefine="True" remove_fill="True"/>
|
||||||
|
</family>
|
||||||
|
</variables>
|
||||||
|
</rougail>
|
16
tests/dictionaries/80remove_fill_no_fill/yml/00-base.yml
Normal file
16
tests/dictionaries/80remove_fill_no_fill/yml/00-base.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
version: '0.10'
|
||||||
|
variables:
|
||||||
|
- family:
|
||||||
|
- name: general
|
||||||
|
variables:
|
||||||
|
- variable:
|
||||||
|
- name: mode_conteneur_actif
|
||||||
|
type: string
|
||||||
|
description: No change
|
||||||
|
value:
|
||||||
|
- text: oui
|
||||||
|
- name: mode_conteneur_actif1
|
||||||
|
type: string
|
||||||
|
description: No change
|
||||||
|
value:
|
||||||
|
- text: non
|
9
tests/dictionaries/80remove_fill_no_fill/yml/01-base.yml
Normal file
9
tests/dictionaries/80remove_fill_no_fill/yml/01-base.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
version: '0.10'
|
||||||
|
variables:
|
||||||
|
- family:
|
||||||
|
- name: general
|
||||||
|
variables:
|
||||||
|
- variable:
|
||||||
|
- name: mode_conteneur_actif
|
||||||
|
redefine: true
|
||||||
|
remove_fill: true
|
Loading…
Reference in a new issue