change Config object

This commit is contained in:
Emmanuel Garette 2020-08-12 08:23:38 +02:00
parent d3670c6476
commit d789787d5c
164 changed files with 661 additions and 194 deletions

View File

@ -3,17 +3,20 @@
fichier de configuration pour rougail
"""
from os.path import join, isfile, abspath, dirname
from pathlib import Path
from os.path import join, abspath, dirname
rougailroot = '/var/rougail'
patch_dir = join(rougailroot, 'patches')
manifests_dir = join(rougailroot, 'manifests')
templates_dir = join(rougailroot, 'templates')
dtddir = join(dirname(abspath(__file__)), 'data')
dtdfilename = join(dtddir, 'rougail.dtd')
Config = {'rougailroot': rougailroot,
'patch_dir': join(rougailroot, 'patches'),
'manifests_dir': join(rougailroot, 'manifests'),
'templates_dir': join(rougailroot, 'templates'),
'dtdfilename': join(dtddir, 'rougail.dtd'),
'dtddir': dtddir,
# chemin du répertoire source des fichiers templates
patch_dir = '/srv/rougail/patch'
variable_namespace = 'rougail'
'patch_dir': '/srv/rougail/patch',
'variable_namespace': 'rougail',
}

View File

@ -32,7 +32,7 @@ from .tiramisureflector import TiramisuReflector
from .utils import normalize_family
from .error import OperationError, SpaceObjShallNotBeUpdated, DictConsistencyError
from .path import Path
from .config import variable_namespace
from .config import Config
# CreoleObjSpace's elements like 'family' or 'follower', that shall be forced to the Redefinable type
FORCE_REDEFINABLES = ('family', 'follower', 'service', 'disknod', 'variables')
@ -329,7 +329,7 @@ class CreoleObjSpace:
def is_already_exists(self, name, space, child, namespace):
if isinstance(space, self.family): # pylint: disable=E1101
if namespace != variable_namespace:
if namespace != Config['variable_namespace']:
name = space.path + '.' + name
return self.paths.path_is_defined(name)
if child.tag == 'family':
@ -362,14 +362,14 @@ class CreoleObjSpace:
else:
norm_name = name
return getattr(family, variable.tag)[norm_name]
if namespace == variable_namespace:
if namespace == Config['variable_namespace']:
path = name
else:
path = family.path + '.' + name
old_family_name = self.paths.get_variable_family_name(path)
if normalize_family(family.name) == old_family_name:
return getattr(family, variable.tag)[name]
old_family = self.space.variables[variable_namespace].family[old_family_name] # pylint: disable=E1101
old_family = self.space.variables[Config['variable_namespace']].family[old_family_name] # pylint: disable=E1101
variable_obj = old_family.variable[name]
del old_family.variable[name]
if 'variable' not in vars(family):
@ -501,7 +501,7 @@ class CreoleObjSpace:
document.attrib.get('dynamic') != None,
variableobj)
if child.attrib.get('redefine', 'False') == 'True':
if namespace == variable_namespace:
if namespace == Config['variable_namespace']:
self.redefine_variables.append(child.attrib['name'])
else:
self.redefine_variables.append(namespace + '.' + family_name + '.' +
@ -509,7 +509,7 @@ class CreoleObjSpace:
elif child.tag == 'family':
family_name = normalize_family(child.attrib['name'])
if namespace != variable_namespace:
if namespace != Config['variable_namespace']:
family_name = namespace + '.' + family_name
self.paths.add_family(namespace,
family_name,

View File

@ -1,7 +1,7 @@
from .i18n import _
from .utils import normalize_family
from .error import OperationError, DictConsistencyError
from .config import variable_namespace
from .config import Config
class Path:
@ -21,7 +21,7 @@ class Path:
name: str,
variableobj: str,
) -> str: # pylint: disable=C0111
if '.' not in name and namespace == variable_namespace:
if '.' not in name and namespace == Config['variable_namespace']:
full_name = '.'.join([namespace, name])
self.full_paths[name] = full_name
else:
@ -41,12 +41,12 @@ class Path:
check_name=False,
allow_dot=True,
)
if '.' not in name and current_namespace == variable_namespace and name in self.full_paths:
if '.' not in name and current_namespace == Config['variable_namespace'] and name in self.full_paths:
name = self.full_paths[name]
if current_namespace is None: # pragma: no cover
raise OperationError('current_namespace must not be None')
dico = self.families[name]
if dico['namespace'] != variable_namespace and current_namespace != dico['namespace']:
if dico['namespace'] != Config['variable_namespace'] and current_namespace != dico['namespace']:
raise DictConsistencyError(_('A family located in the {} namespace '
'shall not be used in the {} namespace').format(
dico['namespace'], current_namespace))
@ -87,7 +87,7 @@ class Path:
False,
dico['variableobj'],
)
if namespace == variable_namespace:
if namespace == Config['variable_namespace']:
self.full_paths[name] = new_path
else:
name = new_path
@ -113,7 +113,7 @@ class Path:
self.full_paths[name] = full_name
else:
full_name = name
if namespace == variable_namespace:
if namespace == Config['variable_namespace']:
name = name.rsplit('.', 1)[1]
self.variables[full_name] = dict(name=name,
family=family,
@ -157,7 +157,7 @@ class Path:
else:
dico = self._get_variable(name)
if not allow_source:
if dico['namespace'] not in [variable_namespace, 'services'] and current_namespace != dico['namespace']:
if dico['namespace'] not in [Config['variable_namespace'], 'services'] and current_namespace != dico['namespace']:
raise DictConsistencyError(_('A variable located in the {} namespace '
'shall not be used in the {} namespace').format(
dico['namespace'], current_namespace))

View File

@ -22,7 +22,7 @@ except:
from tiramisu import Config
from tiramisu.error import PropertiesOptionError
from .config import patch_dir, variable_namespace
from .config import Config
from .error import FileNotFound, TemplateError
from .i18n import _
from .utils import normalize_family
@ -294,7 +294,7 @@ class CreoleTemplateEngine:
patch_no_debug = ['-s', '-r', '-', '--backup-if-mismatch']
# patches variante + locaux
for directory in [join(patch_dir, 'variante'), patch_dir]:
for directory in [join(Config['patch_dir'], 'variante'), Config['patch_dir']]:
patch_file = join(directory, f'{filename}.patch')
if isfile(patch_file):
log.info(_("Patching template '{filename}' with '{patch_file}'"))
@ -376,7 +376,7 @@ class CreoleTemplateEngine:
"""
for option in await self.config.option.list(type='all'):
namespace = await option.option.name()
if namespace == variable_namespace:
if namespace == Config['variable_namespace']:
await self.load_eole_variables_rougail(option)
else:
families = await self.load_eole_variables(namespace,

View File

@ -1,10 +1,7 @@
"""loader
flattened XML specific
"""
from os.path import isfile
from lxml.etree import DTD
from .config import dtdfilename, variable_namespace
from .config import Config
from .i18n import _
from .error import LoaderError
from .annotator import ERASED_ATTRIBUTES
@ -83,10 +80,10 @@ class TiramisuReflector:
# variable_namespace family has to be loaded before any other family
# because `extra` family could use `variable_namespace` variables.
if hasattr(xmlroot, 'variables'):
if variable_namespace in xmlroot.variables:
yield xmlroot.variables[variable_namespace]
if Config['variable_namespace'] in xmlroot.variables:
yield xmlroot.variables[Config['variable_namespace']]
for xmlelt, value in xmlroot.variables.items():
if xmlelt != variable_namespace:
if xmlelt != Config['variable_namespace']:
yield value
if hasattr(xmlroot, 'services'):
yield xmlroot.services

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

View File

@ -1,3 +1,6 @@
try:
from tiramisu3 import *
except:
from tiramisu import *
from rougail.tiramisu import ConvertDynOptionDescription
import imp

Some files were not shown because too many files have changed in this diff Show More