Changed structure of referencing data
This commit is contained in:
@ -1,13 +1,16 @@
|
||||
from ..data import data as data_dir
|
||||
from flask import current_app as app
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from random import shuffle
|
||||
|
||||
def load(filename:str):
|
||||
data_dir = Path(app.config.get('DATA'))
|
||||
with open(f'./{data_dir}/{filename}') as file:
|
||||
return json.load(file)
|
||||
|
||||
def save(data:dict, filename:str):
|
||||
data_dir = Path(app.config.get('DATA'))
|
||||
with open(f'./{data_dir}/{filename}', 'w') as file:
|
||||
json.dump(data, file, indent=4)
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
from ..data import data
|
||||
from flask import current_app as app
|
||||
|
||||
from cryptography.fernet import Fernet
|
||||
from pathlib import Path
|
||||
|
||||
def load_key():
|
||||
data = Path(app.config.get('DATA'))
|
||||
with open(f'./{data}/.encryption.key', 'rb') as keyfile: return keyfile.read()
|
||||
|
||||
def decrypt(input:str):
|
||||
|
@ -1,10 +1,14 @@
|
||||
from ..data import data
|
||||
from flask import current_app as app
|
||||
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
def read(filename:str):
|
||||
data = Path(app.config.get('DATA'))
|
||||
with open(f'./{data}/logs/{filename}') as file:
|
||||
return file.readlines()
|
||||
|
||||
def write(filename:str, message:str):
|
||||
data = Path(app.config.get('DATA'))
|
||||
with open(f'./{data}/logs/{filename}', 'a+') as file:
|
||||
file.write(f'{datetime.now().strftime("%Y-%m-%d-%X")}: {message}\n')
|
Reference in New Issue
Block a user