update code

This commit is contained in:
HibiKier
2021-09-05 02:21:38 +08:00
parent 21a5feda43
commit 7afb099c12
84 changed files with 3377 additions and 1404 deletions
+7 -6
View File
@@ -1,4 +1,4 @@
from typing import Union
from typing import Union, Optional
from pathlib import Path
import ujson as json
@@ -8,12 +8,13 @@ class StaticData:
静态数据共享类
"""
def __init__(self, file: Path):
file.parent.mkdir(exist_ok=True, parents=True)
self.file = file
def __init__(self, file: Optional[Path]):
self.data = {}
if file.exists():
self.data: dict = json.load(open(file, "r", encoding="utf8"))
if file:
file.parent.mkdir(exist_ok=True, parents=True)
self.file = file
if file.exists():
self.data: dict = json.load(open(file, "r", encoding="utf8"))
def set(self, key, value):
self.data[key] = value