You've already forked HeurAMS-legacy
分离算法
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
from .electron import Electron
|
||||
from .nucleon import Nucleon
|
||||
from typing import TypedDict
|
||||
import pathlib
|
||||
import typing
|
||||
import toml
|
||||
import json
|
||||
|
||||
class AtomRegister(TypedDict):
|
||||
nucleon: Nucleon
|
||||
nucleon_path: pathlib.Path
|
||||
nucleon_fmt: str
|
||||
electron: Electron
|
||||
electron_path: pathlib.Path
|
||||
electron_fmt: str
|
||||
orbital: dict
|
||||
orbital_path: pathlib.Path
|
||||
orbital_fmt: str
|
||||
|
||||
class Atom():
|
||||
"""
|
||||
统一处理一系列对象的所有信息与持久化:
|
||||
@@ -14,9 +26,11 @@ class Atom():
|
||||
以及关联路径
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def __init__(self, ident = ""):
|
||||
self.ident = ident
|
||||
self.register = {
|
||||
self.register: AtomRegister = { # type: ignore
|
||||
"nucleon": None,
|
||||
"nucleon_path": None,
|
||||
"nucleon_fmt": "toml",
|
||||
@@ -49,6 +63,17 @@ class Atom():
|
||||
raise KeyError("不受支持的持久化格式")
|
||||
else:
|
||||
raise TypeError("对未初始化的路径对象操作")
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key in self.register:
|
||||
return self.register[key]
|
||||
raise KeyError(f"不支持的键: {key}")
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if key in self.register:
|
||||
self.register[key] = value
|
||||
else:
|
||||
raise KeyError(f"不支持的键: {key}")
|
||||
|
||||
@staticmethod
|
||||
def placeholder():
|
||||
|
||||
Reference in New Issue
Block a user