Used importlib instead of exec

This commit is contained in:
shekhar-cis 2022-08-08 16:26:08 +05:30
parent a6e68a9ff6
commit cb9589f4ba
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7

View File

@ -7,6 +7,7 @@ Bitmessage android(mobile) interface
import ast import ast
import os import os
import importlib
from kivy.lang import Builder from kivy.lang import Builder
from kivy.lang import Observable 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()) all_data = ast.literal_eval(read_file.read())
data_screens = list(all_data.keys()) data_screens = list(all_data.keys())
for modules in data_screens: for key in all_data:
exec(all_data[modules]['Import']) 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): class Lang(Observable):