added support for keys in external files
This commit is contained in:
@ -1,11 +1,21 @@
|
||||
import requests, json, re
|
||||
import requests, json, re, os
|
||||
from datetime import datetime
|
||||
|
||||
def loadSettings() -> dict:
|
||||
# TODO: check integrity
|
||||
try:
|
||||
with open('config.json', 'r') as file:
|
||||
return json.load(file)
|
||||
# Read if the API keys are path to files
|
||||
config = json.load(file)
|
||||
keys = config['api'].keys()
|
||||
mask = dict()
|
||||
for key in keys:
|
||||
api_key = key
|
||||
if os.path.exists(key):
|
||||
with open(key, 'r') as file:
|
||||
api_key = file.readline().strip()
|
||||
mask[key] = api_key
|
||||
config['api'] = { mask[key]: value for key, value in config['api'].items() }
|
||||
except FileNotFoundError:
|
||||
sample_config = {
|
||||
'api': {},
|
||||
|
Reference in New Issue
Block a user