load CUSTOMTYPES every time with all modules
This commit is contained in:
parent
efb8f22872
commit
963fe2a9b6
|
@ -15,8 +15,6 @@ from .utils import _
|
||||||
|
|
||||||
|
|
||||||
MESSAGE_ROOT_PATH = get_config()['global']['message_root_path']
|
MESSAGE_ROOT_PATH = get_config()['global']['message_root_path']
|
||||||
CUSTOMTYPES = {}
|
|
||||||
|
|
||||||
groups.addgroup('message')
|
groups.addgroup('message')
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,13 +386,14 @@ class CustomType:
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
def load_customtypes(current_module_names: str) -> None:
|
def load_customtypes() -> None:
|
||||||
versions = listdir(MESSAGE_ROOT_PATH)
|
versions = listdir(MESSAGE_ROOT_PATH)
|
||||||
versions.sort()
|
versions.sort()
|
||||||
|
ret = {}
|
||||||
for version in versions:
|
for version in versions:
|
||||||
if version not in CUSTOMTYPES:
|
if version not in ret:
|
||||||
CUSTOMTYPES[version] = {}
|
ret[version] = {}
|
||||||
for current_module_name in current_module_names:
|
for current_module_name in listdir(join(MESSAGE_ROOT_PATH, version)):
|
||||||
types_path = join(MESSAGE_ROOT_PATH,
|
types_path = join(MESSAGE_ROOT_PATH,
|
||||||
version,
|
version,
|
||||||
current_module_name,
|
current_module_name,
|
||||||
|
@ -407,10 +406,10 @@ def load_customtypes(current_module_names: str) -> None:
|
||||||
with open(path, "r") as message_file:
|
with open(path, "r") as message_file:
|
||||||
try:
|
try:
|
||||||
custom_type = CustomType(load(message_file, Loader=SafeLoader))
|
custom_type = CustomType(load(message_file, Loader=SafeLoader))
|
||||||
CUSTOMTYPES[version][custom_type.getname()] = custom_type
|
ret[version][custom_type.getname()] = custom_type
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise Exception(_(f'enable to load type {err}: {message}'))
|
raise Exception(_(f'enable to load type {err}: {message}'))
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def _get_description(description,
|
def _get_description(description,
|
||||||
|
@ -577,7 +576,6 @@ def get_messages(current_module_names,
|
||||||
uris=None):
|
uris=None):
|
||||||
"""generate description from yml files
|
"""generate description from yml files
|
||||||
"""
|
"""
|
||||||
global CUSTOMTYPES
|
|
||||||
optiondescriptions = {}
|
optiondescriptions = {}
|
||||||
optiondescriptions_info = {}
|
optiondescriptions_info = {}
|
||||||
messages = list(list_messages(uris,
|
messages = list(list_messages(uris,
|
||||||
|
@ -589,14 +587,6 @@ def get_messages(current_module_names,
|
||||||
'Nom du message.',
|
'Nom du message.',
|
||||||
tuple(optiondescriptions_name),
|
tuple(optiondescriptions_name),
|
||||||
properties=frozenset(['mandatory', 'positional']))
|
properties=frozenset(['mandatory', 'positional']))
|
||||||
if current_module_names is None:
|
|
||||||
CUSTOMTYPES = {}
|
|
||||||
if not CUSTOMTYPES:
|
|
||||||
if current_module_names is None:
|
|
||||||
for version in listdir(MESSAGE_ROOT_PATH):
|
|
||||||
load_customtypes(listdir(join(MESSAGE_ROOT_PATH, version)))
|
|
||||||
else:
|
|
||||||
load_customtypes(current_module_names)
|
|
||||||
for uri in messages:
|
for uri in messages:
|
||||||
message_def = get_message(uri,
|
message_def = get_message(uri,
|
||||||
current_module_names,
|
current_module_names,
|
||||||
|
@ -620,6 +610,7 @@ def get_messages(current_module_names,
|
||||||
|
|
||||||
root = _get_root_option(select_option,
|
root = _get_root_option(select_option,
|
||||||
optiondescriptions)
|
optiondescriptions)
|
||||||
if current_module_names is None:
|
|
||||||
CUSTOMTYPES = {}
|
|
||||||
return optiondescriptions_info, root
|
return optiondescriptions_info, root
|
||||||
|
|
||||||
|
|
||||||
|
CUSTOMTYPES = load_customtypes()
|
||||||
|
|
Loading…
Reference in New Issue