mirror of
https://git.isptech.ru/ISPsystem/isp-maintenance.git
synced 2025-09-13 18:23:08 +02:00
Add: settings values, json parser from file (function), demo example
This commit is contained in:
20
isp_maintenance/utils/helpers.py
Normal file
20
isp_maintenance/utils/helpers.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def parse_json_file(file_path):
|
||||
"""
|
||||
Function read json file as usual config.json then parse it to python dict
|
||||
|
||||
Args:
|
||||
config_file_path (str): path to config file
|
||||
|
||||
Returns:
|
||||
dict: contains parse json content
|
||||
"""
|
||||
try:
|
||||
with open(file_path, 'r') as f:
|
||||
return json.load(f)
|
||||
except Exception as error:
|
||||
print(error)
|
||||
sys.exit(1)
|
Reference in New Issue
Block a user