diff --git a/__pycache__/auxiliary.cpython-313.pyc b/__pycache__/auxiliary.cpython-313.pyc new file mode 100644 index 0000000..bcd17a1 Binary files /dev/null and b/__pycache__/auxiliary.cpython-313.pyc differ diff --git a/__pycache__/particles.cpython-313.pyc b/__pycache__/particles.cpython-313.pyc index 2963c5d..3febeec 100644 Binary files a/__pycache__/particles.cpython-313.pyc and b/__pycache__/particles.cpython-313.pyc differ diff --git a/__pycache__/reactor.cpython-313.pyc b/__pycache__/reactor.cpython-313.pyc index 762f5a4..de9b7aa 100644 Binary files a/__pycache__/reactor.cpython-313.pyc and b/__pycache__/reactor.cpython-313.pyc differ diff --git a/auxiliary.py b/auxiliary.py new file mode 100644 index 0000000..442ca20 --- /dev/null +++ b/auxiliary.py @@ -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 \ No newline at end of file diff --git a/cache/voice/臣密言:臣以险衅, 夙遭闵凶..wav b/cache/voice/臣密言:臣以险衅, 夙遭闵凶..wav new file mode 100644 index 0000000..a0ad0ec Binary files /dev/null and b/cache/voice/臣密言:臣以险衅, 夙遭闵凶..wav differ diff --git a/config.toml b/config.toml index f4795b1..4062be5 100644 --- a/config.toml +++ b/config.toml @@ -1 +1,4 @@ -tasked_number = 8 # 新记忆核子数量 \ No newline at end of file +# 将更改保存到文件 +save = 1 +# 对于每个项目的新记忆核子数量 +tasked_number = 8 \ No newline at end of file diff --git a/main.py b/main.py index 0bfea33..f4904a7 100644 --- a/main.py +++ b/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") diff --git a/particles.py b/particles.py index cf0699f..6b74aae 100644 --- a/particles.py +++ b/particles.py @@ -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): diff --git a/reactor.py b/reactor.py index 663a32d..59db57c 100644 --- a/reactor.py +++ b/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()