进一步实现 interface

This commit is contained in:
2025-11-04 00:07:40 +08:00
parent 0e08fb3a41
commit 4eaff18685
13 changed files with 153 additions and 132 deletions

View File

@@ -1,7 +1,7 @@
from .electron import Electron
from .nucleon import Nucleon
from .orbital import Orbital
from .atom import Atom
from .atom import Atom, atom_registry
from .probe import probe_all, probe_by_filename
from .loader import load_nucleon, load_electron
@@ -14,4 +14,5 @@ __all__ = [
"probe_by_filename",
"load_nucleon",
"load_electron",
"atom_registry",
]

View File

@@ -6,6 +6,7 @@ import pathlib
import typing
import toml
import json
import bidict
class AtomRegister(TypedDict):
nucleon: Nucleon
@@ -17,6 +18,7 @@ class AtomRegister(TypedDict):
orbital: Orbital
orbital_path: pathlib.Path
orbital_fmt: str
runtime: dict
class Atom():
"""
@@ -29,6 +31,7 @@ class Atom():
def __init__(self, ident = ""):
self.ident = ident
atom_registry[ident] = self
self.register: AtomRegister = { # type: ignore
"nucleon": None,
"nucleon_path": None,
@@ -76,4 +79,6 @@ class Atom():
@staticmethod
def placeholder():
return (Electron.placeholder(), Nucleon.placeholder(), {})
return (Electron.placeholder(), Nucleon.placeholder(), {})
atom_registry: bidict.bidict[str, Atom] = bidict.bidict()

View File

@@ -23,4 +23,4 @@ def load_electron(path: pathlib.Path, fmt = "json"):
lst = list()
for item, attr in dictdata.items():
lst.append(Electron(hasher.hash(item), attr))
return lst
return lst