可用性改进
This commit is contained in:
26
auxiliary.py
Normal file
26
auxiliary.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import time
|
||||
import pathlib
|
||||
import toml
|
||||
|
||||
def get_daystamp():
|
||||
#print("Daystamp: ", (time.time() // (24*3600))) # 20292.0
|
||||
return (time.time() // (24*3600))
|
||||
|
||||
class ConfigFile():
|
||||
def __init__(self, path):
|
||||
self.path = pathlib.Path(path)
|
||||
if self.path.exists() == 0:
|
||||
self.path.touch()
|
||||
self.data = dict()
|
||||
with open(self.path, 'r') as f:
|
||||
self.data = toml.load(f)
|
||||
def modify(self, key, value):
|
||||
self.data[key] = value
|
||||
self.save()
|
||||
def save(self, path=""):
|
||||
if path == "":
|
||||
path = self.path
|
||||
with open(path, 'w') as f:
|
||||
toml.dump(self.data, f)
|
||||
def get(self, key, default = None):
|
||||
pass
|
Reference in New Issue
Block a user