feat(kernel): 状态机改进
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
import json
|
||||
import pathlib
|
||||
import typing
|
||||
from typing import TypedDict
|
||||
|
||||
import toml
|
||||
|
||||
from heurams.services.logger import get_logger
|
||||
|
||||
@@ -22,6 +18,7 @@ class AtomRegister_runtime(TypedDict):
|
||||
class AtomRegister(TypedDict):
|
||||
nucleon: Nucleon
|
||||
electron: Electron
|
||||
orbital: dict
|
||||
runtime: AtomRegister_runtime
|
||||
|
||||
|
||||
@@ -99,3 +96,8 @@ class Atom:
|
||||
if key == "ident":
|
||||
raise AttributeError("应为只读")
|
||||
self.registry[key] = value
|
||||
|
||||
def __repr__(self):
|
||||
from pprint import pformat
|
||||
s = pformat(self.registry, indent=4)
|
||||
return s
|
||||
|
||||
@@ -13,12 +13,15 @@ class Nucleon:
|
||||
self.ident = ident
|
||||
env = {"payload": payload}
|
||||
self.evalizer = Evalizer(environment=env)
|
||||
self.data = self.evalizer(deepcopy((payload | common)))
|
||||
self.data: dict = self.evalizer(deepcopy((payload | common))) # type: ignore
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key == "ident":
|
||||
return self.ident
|
||||
return self.data[key]
|
||||
if isinstance(key, str):
|
||||
if key == "ident":
|
||||
return self.ident
|
||||
return self.data[key]
|
||||
else:
|
||||
raise AttributeError
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
raise AttributeError("应为只读")
|
||||
|
||||
Reference in New Issue
Block a user