diff --git a/src/main/utils/utils.py b/src/main/utils/utils.py new file mode 100644 index 0000000..eb007c8 --- /dev/null +++ b/src/main/utils/utils.py @@ -0,0 +1,36 @@ +import json + +try: + with open('background.json') as infile: + background = json.load(infile) + print('\"background.json\" loaded.') +except FileNotFoundError: + with open('background.json', 'w+') as iofile: + print('Background file not found: \"background.json\" created and loaded.') + json.dump({}, iofile, indent=4, sort_keys=True) + iofile.seek(0) + background = json.load(iofile) + +with open('config.json') as infile: + config = json.load(infile) + +def update(out, file): + with open(file, 'w') as outfile: + json.dump(out, outfile, indent=4, sort_keys=True) + +import asyncio + +async def clear(obj, interval=10*60, replace=None): + if replace is None: + if type(obj) is list: + replace = [] + elif type(obj) is dict: + replace = {} + elif type(obj) is int: + replace = 0 + elif type(obj) is str: + replace = '' + + while True: + obj = replace + asyncio.sleep(interval)