Changed structure of referencing data

This commit is contained in:
2022-06-19 13:22:05 +01:00
parent 76fa1e1dd9
commit ac02f4dee1
8 changed files with 25 additions and 16 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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')