You've already forked HeurAMS-legacy
style: 代码格式化
This commit is contained in:
@@ -29,12 +29,13 @@ class Nucleon:
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.ident)
|
||||
|
||||
|
||||
def do_eval(self):
|
||||
"""
|
||||
执行并以结果替换当前单元的所有 eval 语句
|
||||
TODO: 带有限制的 eval, 异步/多线程执行避免堵塞
|
||||
"""
|
||||
|
||||
# eval 环境设置
|
||||
def eval_with_env(s: str):
|
||||
try:
|
||||
@@ -43,7 +44,7 @@ class Nucleon:
|
||||
except Exception as e:
|
||||
ret = f"此 eval 实例发生错误: {e}"
|
||||
return ret
|
||||
|
||||
|
||||
def traverse(data, modifier):
|
||||
if isinstance(data, dict):
|
||||
for key, value in data.items():
|
||||
@@ -60,9 +61,10 @@ class Nucleon:
|
||||
if data.startswith("eval:"):
|
||||
return modifier(data[5:])
|
||||
return data
|
||||
|
||||
|
||||
traverse(self.payload, eval_with_env)
|
||||
traverse(self.metadata, eval_with_env)
|
||||
|
||||
@staticmethod
|
||||
def placeholder():
|
||||
"""生成一个占位原子核"""
|
||||
|
||||
Reference in New Issue
Block a user