v0.2.4 基本可用型
This commit is contained in:
27
particles.py
27
particles.py
@@ -36,6 +36,17 @@ class Electron():
|
||||
setattr(self, var, value)
|
||||
self.last_modify = time.time()
|
||||
|
||||
def export_data(self):
|
||||
return {
|
||||
'efactor': self.efactor,
|
||||
'real_rept': self.real_rept,
|
||||
'rept': self.rept,
|
||||
'interval': self.interval,
|
||||
'last_date': self.last_date,
|
||||
'next_date': self.next_date,
|
||||
'is_activated': self.is_activated
|
||||
}
|
||||
|
||||
def revisor(self, quality):
|
||||
"""SM-2 算法迭代决策机制实现
|
||||
根据 quality(0 ~ 5) 进行参数迭代最佳间隔
|
||||
@@ -66,7 +77,7 @@ class Electron():
|
||||
self.interval = round(self.interval * self.efactor)
|
||||
|
||||
self.last_date = aux.get_daystamp()
|
||||
self.next_date = self.last_date + self.interval
|
||||
self.next_date = aux.get_daystamp() + self.interval
|
||||
|
||||
def __str__(self):
|
||||
return (f"记忆单元预览 \n"
|
||||
@@ -98,9 +109,9 @@ class Electron():
|
||||
lst.append(Electron(i, all[i]))
|
||||
return (name, lst)
|
||||
@staticmethod
|
||||
def save_to_file(electron_list, path: pathlib.Path):
|
||||
def save_to_file(electron_dictized, path: pathlib.Path):
|
||||
with open(path, 'w') as f:
|
||||
toml.dump(electron_list, f)
|
||||
toml.dump(electron_dictized, f)
|
||||
|
||||
class Nucleon():
|
||||
"""核子: 材料元数据"""
|
||||
@@ -119,9 +130,9 @@ class Nucleon():
|
||||
return (name, lst)
|
||||
|
||||
@staticmethod
|
||||
def save_to_file(nucleon_list, path: pathlib.Path):
|
||||
def save_to_file(nucleon_dictized, path: pathlib.Path):
|
||||
with open(path, 'w') as f:
|
||||
toml.dump(nucleon_list, f)
|
||||
toml.dump(nucleon_dictized, f)
|
||||
|
||||
@staticmethod
|
||||
def placeholder():
|
||||
@@ -136,10 +147,12 @@ class AtomicFile():
|
||||
if type_ == "electron":
|
||||
self.name, self.datalist = Electron.import_from_file(pathlib.Path(path))
|
||||
def save(self):
|
||||
dictobj = {i.content: i.export_data() for i in self.datalist}
|
||||
print(dictobj)
|
||||
if self.type_ == "nucleon":
|
||||
Nucleon.save_to_file(self.datalist, self.path)
|
||||
Nucleon.save_to_file(dictobj, self.path)
|
||||
if self.type_ == "electron":
|
||||
Electron.save_to_file(self.datalist, self.path)
|
||||
Electron.save_to_file(dictobj, self.path)
|
||||
def get_full_content(self):
|
||||
if self.type_ == "nucleon":
|
||||
text = ""
|
||||
|
Reference in New Issue
Block a user