TG-PlatformPlus/environment.py

31 lines
657 B
Python

#!/opt/homebrew/bin/python3
# -*- coding:utf-8 -*-
import json
import os
from logs import log
from config import config
class Enviroment():
def __init__(self):
super().__init__()
self.data = dict()
self.data['config'] = config.data
def update(self, key, val):
if isinstance(key, str):
self.data[key] = val
else:
log.error('failed to set key val to env:', key, val)
def relaodConfig(self):
self.data['config'] = config.data
def toDict(self):
return self.data
def toJson(self):
return json.dumps(self.data, indent=4)
env = Enviroment()