diff --git a/toolium/test/utils/test_dataset_map_param.py b/toolium/test/utils/test_dataset_map_param.py index 3c76e2f4..ca168d81 100644 --- a/toolium/test/utils/test_dataset_map_param.py +++ b/toolium/test/utils/test_dataset_map_param.py @@ -1,8 +1,20 @@ # -*- coding: utf-8 -*- - -# Copyright (c) Telefónica Digital. -# QA Team - +""" +Copyright 2022 Telefónica Investigación y Desarrollo, S.A.U. +This file is part of Toolium. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" import mock import os diff --git a/toolium/test/utils/test_poeditor.py b/toolium/test/utils/test_poeditor.py index f8959fcd..333025ef 100644 --- a/toolium/test/utils/test_poeditor.py +++ b/toolium/test/utils/test_poeditor.py @@ -1,8 +1,20 @@ # -*- coding: utf-8 -*- +""" +Copyright 2022 Telefónica Investigación y Desarrollo, S.A.U. +This file is part of Toolium. -# Copyright (c) Telefónica Digital. -# QA Team +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" import mock diff --git a/toolium/utils/dataset.py b/toolium/utils/dataset.py index 9c4d25db..4405aef9 100644 --- a/toolium/utils/dataset.py +++ b/toolium/utils/dataset.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Copyright 2021 Telefónica Investigación y Desarrollo, S.A.U. +Copyright 2022 Telefónica Investigación y Desarrollo, S.A.U. This file is part of Toolium. Licensed under the Apache License, Version 2.0 (the "License"); @@ -322,23 +322,52 @@ def map_one_param(param, context=None): return param type, key = _get_mapping_type_and_key(param) - if key: - if type == "CONF" and context and hasattr(context, "project_config"): - return map_json_param(key, context.project_config) - if type == "TOOLIUM" and context: - return map_toolium_param(key, context) - if type == "CONTEXT" and context: - return get_value_from_context(key, context) - if type == "LANG" and context: - return get_message_property(key, context) - if type == "POE" and context: - return get_translation_by_poeditor_reference(key, context) - if type == "ENV": - return os.environ.get(key) - if type == "FILE": - return get_file(key) - if type == "BASE64": - return convert_file_to_base64(key) + + mapping_functions = { + "CONF": { + "prerequisites": context and hasattr(context, "project_config"), + "function": map_json_param, + "args": [key, context.project_config if hasattr(context, "project_config") else None] + }, + "TOOLIUM": { + "prerequisites": context, + "function": map_toolium_param, + "args": [key, context] + }, + "CONTEXT": { + "prerequisites": context, + "function": get_value_from_context, + "args": [key, context] + }, + "LANG": { + "prerequisites": context, + "function": get_message_property, + "args": [key, context] + }, + "POE": { + "prerequisites": context, + "function": get_translation_by_poeditor_reference, + "args": [key, context] + }, + "ENV": { + "prerequisites": True, + "function": os.environ.get, + "args": [key] + }, + "FILE": { + "prerequisites": True, + "function": get_file, + "args": [key] + }, + "BASE64": { + "prerequisites": True, + "function": convert_file_to_base64, + "args": [key] + } + } + + if key and mapping_functions[type]["prerequisites"]: + return mapping_functions[type]["function"](*mapping_functions[type]["args"]) else: return param diff --git a/toolium/utils/poeditor.py b/toolium/utils/poeditor.py index 5cb5b360..2417a2bf 100644 --- a/toolium/utils/poeditor.py +++ b/toolium/utils/poeditor.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -Copyright 2021 Telefónica Investigación y Desarrollo, S.A.U. +Copyright 2022 Telefónica Investigación y Desarrollo, S.A.U. This file is part of Toolium. Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,7 +41,7 @@ "poeditor": { "base_url": "https://api.poeditor.com", "api_token": "XXXXX", - "project_name": "Aura-Bot", + "project_name": "My-Bot", "prefixes": [], "key_field": "reference", "search_type": "contains",