Skip to content

Commit

Permalink
feat(Console, ConsolePlus): ✨ Update the print_out function followi…
Browse files Browse the repository at this point in the history
  • Loading branch information
ARCJ137442 committed Sep 22, 2023
1 parent ca68d9f commit e20326f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 36 deletions.
28 changes: 13 additions & 15 deletions pynars/Console.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,21 @@ def handle_lines(nars: Reasoner, lines: str):
if tasks_line is not None:
tasks_lines.extend(tasks_line)
# print the output #
tasks_lines: List[
Tuple[
List[Task], Task,
Task, List[Task],
Task, Tuple[Task, Task]
]
]
tasks_lines: List[Tuple[
List[Task],
Task,
Task,
List[Task],
Task,
Tuple[Task, Task]]]
for tasks_line in tasks_lines:
# unpack one of lines of tasks, and then print out
(
tasks_derived,
judgement_revised,
goal_revised,
answers_question,
answers_quest,
(task_operation_return, task_executed)
) = tasks_line
(tasks_derived,
judgement_revised,
goal_revised,
answers_question,
answers_quest,
(task_operation_return, task_executed)) = tasks_line
# while derived task(s)
for task in tasks_derived:
print_out(
Expand Down
36 changes: 15 additions & 21 deletions pynars/Interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,37 +438,31 @@ def _handleLines(self, lines: str) -> list[NARSOutput]:
]
]
for taskLine in taskList:
(
tasksDerived,
judgementRevised,
goalRevised,
answersQuestion,
answersQuest,
(taskOperationReturn, taskExecuted)
) = taskLine
for derivedTask in tasksDerived:
tasks_derived, judgement_revised, goal_revised, answers_question, answers_quest,\
(task_operation_return, task_executed) = taskLine
for derivedTask in tasks_derived:
outs.append(
NARSOutput(
PrintType.OUT, derivedTask.sentence.repr(), *derivedTask.budget)
)

if judgementRevised is not None:
outs.append(NARSOutput(PrintType.OUT, judgementRevised.sentence.repr(
), *judgementRevised.budget))
if goalRevised is not None:
if judgement_revised is not None:
outs.append(NARSOutput(PrintType.OUT, judgement_revised.sentence.repr(
), *judgement_revised.budget))
if goal_revised is not None:
outs.append(NARSOutput(
PrintType.OUT, goalRevised.sentence.repr(), *goalRevised.budget))
if answersQuestion is not None:
for answer in answersQuestion:
PrintType.OUT, goal_revised.sentence.repr(), *goal_revised.budget))
if answers_question is not None:
for answer in answers_question:
outs.append(
NARSOutput(PrintType.ANSWER, answer.sentence.repr(), *answer.budget))
if answersQuest is not None:
for answer in answersQuest:
if answers_quest is not None:
for answer in answers_quest:
outs.append(NARSOutput(
PrintType.ANSWER, answersQuest.sentence.repr(), *answersQuest.budget))
if taskExecuted is not None:
PrintType.ACHIEVED, answers_quest.sentence.repr(), *answers_quest.budget))
if task_executed is not None:
outs.append(NARSOutput(
PrintType.EXE, f'{taskExecuted.term.repr()} = {str(taskOperationReturn) if taskOperationReturn is not None else None}'))
PrintType.EXE, f'{task_executed.term.repr()} = {str(task_operation_return) if task_operation_return is not None else None}'))

# * print & event patch
for out in outs:
Expand Down

0 comments on commit e20326f

Please sign in to comment.