改各种小问题
This commit is contained in:
@@ -177,7 +177,7 @@ def remove_mem_edge(hippocampus: Hippocampus):
|
||||
|
||||
# 修改节点信息
|
||||
def alter_mem_node(hippocampus: Hippocampus):
|
||||
batchEnviroment = dict()
|
||||
batch_environment = dict()
|
||||
while True:
|
||||
concept = input("请输入节点概念名(输入'终止'以结束):\n")
|
||||
if concept.lower() == "终止":
|
||||
@@ -229,7 +229,7 @@ def alter_mem_node(hippocampus: Hippocampus):
|
||||
break
|
||||
|
||||
try:
|
||||
user_exec(command, node_environment, batchEnviroment)
|
||||
user_exec(command, node_environment, batch_environment)
|
||||
except Exception as e:
|
||||
console.print(e)
|
||||
console.print(
|
||||
@@ -239,7 +239,7 @@ def alter_mem_node(hippocampus: Hippocampus):
|
||||
|
||||
# 修改边信息
|
||||
def alter_mem_edge(hippocampus: Hippocampus):
|
||||
batchEnviroment = dict()
|
||||
batch_enviroment = dict()
|
||||
while True:
|
||||
source = input("请输入 **第一个节点** 名称(输入'终止'以结束):\n")
|
||||
if source.lower() == "终止":
|
||||
@@ -262,21 +262,21 @@ def alter_mem_edge(hippocampus: Hippocampus):
|
||||
console.print("[yellow]你将获得一个执行任意代码的环境[/yellow]")
|
||||
console.print("[red]你已经被警告过了。[/red]\n")
|
||||
|
||||
edgeEnviroment = {"source": "<节点名>", "target": "<节点名>", "strength": "<强度值,装在一个list里>"}
|
||||
edge_environment = {"source": "<节点名>", "target": "<节点名>", "strength": "<强度值,装在一个list里>"}
|
||||
console.print(
|
||||
"[green]环境变量中会有env与batchEnv两个dict, env在切换节点时会清空, batchEnv在操作终止时才会清空[/green]"
|
||||
)
|
||||
console.print(
|
||||
f"[green] env 会被初始化为[/green]\n{edgeEnviroment}\n[green]且会在用户代码执行完毕后被提交 [/green]"
|
||||
f"[green] env 会被初始化为[/green]\n{edge_environment}\n[green]且会在用户代码执行完毕后被提交 [/green]"
|
||||
)
|
||||
console.print(
|
||||
"[yellow]为便于书写临时脚本,请手动在输入代码通过Ctrl+C等方式触发KeyboardInterrupt来结束代码执行[/yellow]"
|
||||
)
|
||||
|
||||
# 拷贝数据以防操作炸了
|
||||
edgeEnviroment["strength"] = [edge["strength"]]
|
||||
edgeEnviroment["source"] = source
|
||||
edgeEnviroment["target"] = target
|
||||
edge_environment["strength"] = [edge["strength"]]
|
||||
edge_environment["source"] = source
|
||||
edge_environment["target"] = target
|
||||
|
||||
while True:
|
||||
|
||||
@@ -288,8 +288,8 @@ def alter_mem_edge(hippocampus: Hippocampus):
|
||||
except KeyboardInterrupt:
|
||||
# 稍微防一下小天才
|
||||
try:
|
||||
if isinstance(edgeEnviroment["strength"][0], int):
|
||||
edge["strength"] = edgeEnviroment["strength"][0]
|
||||
if isinstance(edge_environment["strength"][0], int):
|
||||
edge["strength"] = edge_environment["strength"][0]
|
||||
else:
|
||||
raise Exception
|
||||
|
||||
@@ -301,7 +301,7 @@ def alter_mem_edge(hippocampus: Hippocampus):
|
||||
break
|
||||
|
||||
try:
|
||||
user_exec(command, edgeEnviroment, batchEnviroment)
|
||||
user_exec(command, edge_environment, batch_enviroment)
|
||||
except Exception as e:
|
||||
console.print(e)
|
||||
console.print(
|
||||
|
||||
Reference in New Issue
Block a user