mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
6a708e55e6
- moved config to documents - reduced readme - updated requirements - action key implemented - when non saved config is get for the first time, default is saved - added icon - added unhandled exception logging - added debug mode - made dark mode and debug mode check buttons instead of command - created manifest - moved addon to a zip
32 lines
772 B
Python
32 lines
772 B
Python
import json
|
|
import os
|
|
from threading import Thread
|
|
|
|
filename = os.path.expanduser(r"~/Documents/fishy_config.json")
|
|
|
|
|
|
class Config:
|
|
|
|
def __init__(self):
|
|
self.config_dict = json.loads(open(filename).read()) if os.path.exists(filename) else dict()
|
|
|
|
def get(self, key, default=None, save=True):
|
|
if key in self.config_dict:
|
|
return self.config_dict[key]
|
|
|
|
if save:
|
|
self.set(key, default)
|
|
return default
|
|
|
|
def set(self, key, value, save=True):
|
|
self.config_dict[key] = value
|
|
if save:
|
|
self.save_config()
|
|
|
|
def save_config(self):
|
|
def save():
|
|
with open(filename, 'w') as f:
|
|
f.write(json.dumps(self.config_dict))
|
|
|
|
Thread(target=save).start()
|