Add separate function to load json

This commit is contained in:
shekhar-cis 2022-09-01 13:56:47 +05:30
parent 75c6bbd042
commit 8d72ab380d
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
2 changed files with 26 additions and 1 deletions

View File

@ -140,7 +140,7 @@ if __name__ == "__main__":
package_data={'': [
'bitmessageqt/*.ui', 'bitmsghash/*.cl', 'sslkeys/*.pem',
'translations/*.ts', 'translations/*.qm', 'default.ini', 'sql/*.sql',
'images/*.png', 'images/*.ico', 'images/*.icns'
'images/*.png', 'images/*.ico', 'images/*.icns', 'bitmessagekivy/screens_data.json'
]},
data_files=data_files,
ext_modules=[bitmsghash],

View File

@ -0,0 +1,25 @@
"""
Load kivy screens data from json
"""
import os
import json
import importlib
data_screen_dict = {}
def load_screen_json(data_file="screens_data.json"):
"""Load screens data from json"""
with open(os.path.join(os.path.dirname(__file__), data_file)) as read_file:
all_data = json.load(read_file)
data_screens = list(all_data.keys())
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()
data_screen_dict[import_to] = importlib.import_module(import_from, import_to)
return data_screens, all_data, data_screen_dict, 'success'