From cb9589f4baa1305549d3e1730deaff62cddbd6aa Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Mon, 8 Aug 2022 16:26:08 +0530 Subject: [PATCH] Used importlib instead of exec --- src/bitmessagekivy/mpybit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 65aaebf6..a1577b3c 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -7,6 +7,7 @@ Bitmessage android(mobile) interface import ast import os +import importlib from kivy.lang import Builder from kivy.lang import Observable @@ -21,8 +22,12 @@ with open(os.path.join(os.path.dirname(__file__), "screens_data.json")) as read_ all_data = ast.literal_eval(read_file.read()) data_screens = list(all_data.keys()) -for modules in data_screens: - exec(all_data[modules]['Import']) +for key in all_data: + if all_data[key]['Import']: + import_data = all_data.get(key)['Import'] + import_to = import_data.split("import")[1].strip() + import_from = import_data.split("import")[0].split('from')[1].strip() + importlib.import_module(import_from, import_to) class Lang(Observable):