Add separate function to load json
This commit is contained in:
parent
75c6bbd042
commit
8d72ab380d
2
setup.py
2
setup.py
|
@ -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],
|
||||
|
|
25
src/bitmessagekivy/load_kivy_screens_data.py
Normal file
25
src/bitmessagekivy/load_kivy_screens_data.py
Normal 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'
|
Reference in New Issue
Block a user