中途改进
This commit is contained in:
29
particles.py
29
particles.py
@@ -122,16 +122,7 @@ class Nucleon():
|
||||
def __init__(self, content: str, data: dict):
|
||||
self.metadata = data
|
||||
self.content = content
|
||||
|
||||
@staticmethod
|
||||
def import_from_file(path: pathlib.Path):
|
||||
name = path.name.replace(path.suffix, "")
|
||||
with open(path, 'r') as f:
|
||||
all = toml.load(f)
|
||||
lst = list()
|
||||
for i in all.keys():
|
||||
lst.append(Nucleon(i, all[i]))
|
||||
return (name, lst)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def save_to_file(nucleon_dictized, path: pathlib.Path):
|
||||
@@ -142,6 +133,24 @@ class Nucleon():
|
||||
def placeholder():
|
||||
return Nucleon("核子对象样例内容", {})
|
||||
|
||||
class NucleonUnion():
|
||||
"取代原有 NucleonFile 类, 以支持复杂逻辑"
|
||||
def __init__(self, path):
|
||||
name = path.name.replace(path.suffix, "")
|
||||
with open(path, 'r') as f:
|
||||
all = toml.load(f)
|
||||
lst = list()
|
||||
for i in all.keys():
|
||||
if "data" in i:
|
||||
continue
|
||||
lst.append(Nucleon(i, all[i]))
|
||||
self.keydata = all["keydata"]
|
||||
self.testdata = all["testdata"]
|
||||
self.nucleons = lst
|
||||
self.nucleons_dict =
|
||||
def query(content):
|
||||
|
||||
|
||||
class AtomicFile():
|
||||
def __init__(self, path, type_="unknown"):
|
||||
self.path = path
|
||||
|
Reference in New Issue
Block a user