Skip to content

Commit

Permalink
Added custom formatting function to tree nodes when rendering AlterLo…
Browse files Browse the repository at this point in the history
…gs as tree on console.
  • Loading branch information
Paebbels committed Jun 2, 2024
1 parent 2490e17 commit 7ddfe7a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pyEDAA/Reports/OSVVM/AlertLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def __bool__(self) -> bool:
return self is self.Passed


def _format(node: Node) -> str:
return f"{node._value}: {node["TotalErrors"]}={node["AlertCountFailures"]}/{node["AlertCountErrors"]}/{node["AlertCountWarnings"]} {node["PassedCount"]}/{node["AffirmCount"]}"


@export
class AlertLogGroup(metaclass=ExtendedType, slots=True):
_parent: "AlertLogGroup"
Expand Down Expand Up @@ -190,7 +194,19 @@ def __getitem__(self, name: str) -> "AlertLogGroup":
return self._chilren[name]

def ToTree(self) -> Node:
node = Node(value=self._name, children=(child.ToTree() for child in self._children.values()))
node = Node(
value=self._name,
keyValuePairs={
"TotalErrors": self._totalErrors,
"AlertCountFailures": self._alertCountFailures,
"AlertCountErrors": self._alertCountErrors,
"AlertCountWarnings": self._alertCountWarnings,
"PassedCount": self._passedCount,
"AffirmCount": self._affirmCount
},
children=(child.ToTree() for child in self._children.values()),
format=_format
)

return node

Expand Down

0 comments on commit 7ddfe7a

Please sign in to comment.