可用性改进
This commit is contained in:
BIN
__pycache__/auxiliary.cpython-313.pyc
Normal file
BIN
__pycache__/auxiliary.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
|
BIN
cache/voice/臣密言:臣以险衅, 夙遭闵凶..wav
vendored
Normal file
BIN
cache/voice/臣密言:臣以险衅, 夙遭闵凶..wav
vendored
Normal file
Binary file not shown.
@@ -1 +1,4 @@
|
||||
tasked_number = 8 # 新记忆核子数量
|
||||
# 将更改保存到文件
|
||||
save = 1
|
||||
# 对于每个项目的新记忆核子数量
|
||||
tasked_number = 8
|
9
main.py
9
main.py
@@ -43,6 +43,8 @@ class MemScreen(Screen):
|
||||
self.reactor = Reactor(nucleon_file, electron_file, tasked_num)
|
||||
self.stage = 1
|
||||
self.stage += self.reactor.set_round_templated(self.stage)
|
||||
#print(self.reactor.procession)
|
||||
self.reactor.forward()
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
@@ -103,7 +105,8 @@ class MemScreen(Screen):
|
||||
if ret == -1:
|
||||
if self.reactor.round_set == 0:
|
||||
if self.stage == 3:
|
||||
# NOTE # self.reactor.save()
|
||||
# NOTE #
|
||||
#self.reactor.save()
|
||||
self._show_finished_screen("今日目标已完成")
|
||||
else:
|
||||
self.stage += 1
|
||||
@@ -116,7 +119,9 @@ class MemScreen(Screen):
|
||||
|
||||
def action_play_voice(self):
|
||||
def play():
|
||||
cache = pathlib.Path(f"./cache/voice/{self.reactor.current_atom[1].content}.wav")
|
||||
cache_dir = pathlib.Path(f"./cache/voice/")
|
||||
cache_dir.mkdir(parents = True, exist_ok = True)
|
||||
cache = cache_dir / f"{self.reactor.current_atom[1].content}.wav"
|
||||
if not cache.exists():
|
||||
communicate = tts.Communicate(self.reactor.current_atom[1].content, "zh-CN-YunjianNeural")
|
||||
communicate.save_sync(f"./cache/voice/{self.reactor.current_atom[1].content}.wav")
|
||||
|
@@ -1,11 +1,7 @@
|
||||
import pathlib
|
||||
import toml
|
||||
import time
|
||||
|
||||
class Aux():
|
||||
@staticmethod
|
||||
def get_daystamp():
|
||||
return (time.time() // (24*3600))
|
||||
import auxiliary as aux
|
||||
|
||||
class Electron():
|
||||
"""电子: 记忆分析元数据及算法"""
|
||||
@@ -69,7 +65,7 @@ class Electron():
|
||||
else:
|
||||
self.interval = round(self.interval * self.efactor)
|
||||
|
||||
self.last_date = Aux.get_daystamp()
|
||||
self.last_date = aux.get_daystamp()
|
||||
self.next_date = self.last_date + self.interval
|
||||
|
||||
def __str__(self):
|
||||
|
20
reactor.py
20
reactor.py
@@ -1,22 +1,31 @@
|
||||
import typing
|
||||
import particles as pt
|
||||
import pathlib
|
||||
import auxiliary as aux
|
||||
class Parser():
|
||||
"""轻量级版本文件解析器, 用于解析记忆状态"""
|
||||
|
||||
class Reactor():
|
||||
"""反应堆对象, 用于处理 & 分配一次文件记忆流程的资源/策略"""
|
||||
def __init__(self, nucleon_file: pt.AtomicFile, electron_file: pt.AtomicFile, tasked_num):
|
||||
# 导入原子对象
|
||||
self.reported = set()
|
||||
self.nucleon_file = nucleon_file
|
||||
self.electron_file = electron_file
|
||||
self.tasked_num = tasked_num
|
||||
self.atoms_new: typing.List[typing.Tuple[pt.Electron, pt.Nucleon]] = list()
|
||||
self.atoms_review: typing.List[typing.Tuple[pt.Electron, pt.Nucleon]] = list()
|
||||
for atom in zip(electron_file.datalist, nucleon_file.datalist):
|
||||
self.atoms_new = list()
|
||||
self.atoms_review = list()
|
||||
|
||||
electron_dict = {elect.content: elect for elect in electron_file.datalist}
|
||||
|
||||
for nucleon in nucleon_file.datalist:
|
||||
atom = (electron_dict.get(nucleon_file, pt.Electron.placeholder()), nucleon)
|
||||
if atom[0].is_activated == 0:
|
||||
atom[0].is_activated = 1
|
||||
self.atoms_new.append(atom)
|
||||
else:
|
||||
if atom[0].next_date <= pt.Aux.get_daystamp():
|
||||
atom[0].last_date = pt.Aux.get_daystamp()
|
||||
if atom[0].next_date <= aux.get_daystamp():
|
||||
atom[0].last_date = aux.get_daystamp()
|
||||
self.atoms_review.append(atom)
|
||||
# 设置运行时
|
||||
self.index: int
|
||||
@@ -71,6 +80,7 @@ class Reactor():
|
||||
return 0
|
||||
|
||||
def save(self):
|
||||
print("Progress saved")
|
||||
self.nucleon_file.save()
|
||||
self.electron_file.save()
|
||||
|
||||
|
Reference in New Issue
Block a user