1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import json
- import os
- def init_provider_rules():
-
- subdirectory_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rules')
-
- providers_json_file_path = os.path.join(subdirectory_path, '_providers.json')
- try:
-
- with open(providers_json_file_path, 'r') as json_file:
- data = json.load(json_file)
-
- provider_names = data
- except FileNotFoundError:
- return "JSON file not found or path error"
- except json.JSONDecodeError:
- return "JSON file decoding error"
-
- json_data = {}
- try:
-
- for provider_name in provider_names:
- filename = provider_name + '.json'
-
- json_file_path = os.path.join(subdirectory_path, filename)
-
- with open(json_file_path, 'r') as json_file:
- data = json.load(json_file)
-
- json_data[os.path.splitext(filename)[0]] = data
- return json_data
- except FileNotFoundError:
- return "JSON file not found or path error"
- except json.JSONDecodeError:
- return "JSON file decoding error"
- provider_rules = init_provider_rules()
|