Archived
0
0

fix: 改进

This commit is contained in:
2025-12-16 03:28:29 +08:00
parent 5e4b0508eb
commit 5f2e8f6523
19 changed files with 1076 additions and 61 deletions

View File

@@ -74,12 +74,17 @@ class Atom:
# eval 环境设置
def eval_with_env(s: str):
# 初始化默认值
nucleon = self.registry["nucleon"]
default = {}
metadata = {}
try:
nucleon = self.registry["nucleon"]
default = config_var.get()["puzzles"]
metadata = nucleon.metadata
except:
ret = "尚未链接对象"
except Exception:
# 如果无法获取配置或元数据,使用空字典
logger.debug("无法获取配置或元数据,使用空字典")
pass
try:
eval_value = eval(s)
if isinstance(eval_value, (list, dict)):
@@ -110,8 +115,24 @@ class Atom:
return modifier(data[5:])
return data
traverse(self.registry["nucleon"], eval_with_env)
traverse(self.registry["orbital"], eval_with_env)
# 如果 nucleon 存在且有 do_eval 方法,调用它
nucleon = self.registry["nucleon"]
if nucleon is not None and hasattr(nucleon, 'do_eval'):
nucleon.do_eval()
logger.debug("已调用 nucleon.do_eval")
# 如果 electron 存在且其 algodata 包含 eval 字符串,遍历它
electron = self.registry["electron"]
if electron is not None and hasattr(electron, 'algodata'):
traverse(electron.algodata, eval_with_env)
logger.debug("已处理 electron algodata eval")
# 如果 orbital 存在且是字典,遍历它
orbital = self.registry["orbital"]
if orbital is not None and isinstance(orbital, dict):
traverse(orbital, eval_with_env)
logger.debug("orbital eval 完成")
logger.debug("Atom.do_eval 完成")
def persist(self, key):