move mthod to helpers
Utility/common code of library.
"""
-__author__ = 'Grzegorz Latuszek, Michal Ernst'
+__author__ = 'Grzegorz Latuszek, Michal Ernst, Marcin Usielski'
__copyright__ = 'Copyright (C) 2018, Nokia'
-__email__ = 'grzegorz.latuszek@nokia.com, michal.ernst@nokia.com'
+__email__ = 'grzegorz.latuszek@nokia.com, michal.ernst@nokia.com, marcin.usielski@nokia.com'
import re
+import importlib
class ClassProperty(property):
@@ -50,3 +51,14 @@ def remove_escape_codes(line):
"""
line = re.sub(_re_escape_codes, "", line)
return line
+
+
+def create_object_from_name(full_class_name, constructor_params):
+ name_splitted = full_class_name.split('.')
+ module_name = ".".join(name_splitted[:-1])
+ class_name = name_splitted[-1]
+
+ imported_module = importlib.import_module(module_name)
+ class_imported = getattr(imported_module, class_name)
+ obj = class_imported(constructor_params)
+ return obj
