Skip to content

Commit

Permalink
fix #5020 "Stethoscope node cannot show count of objects if items are…
Browse files Browse the repository at this point in the history
… objects".
satabol committed Oct 16, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fad7b2c commit 95a22d8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions utils/sv_stethoscope_helper.py
Original file line number Diff line number Diff line change
@@ -73,15 +73,18 @@ def draw_text(color, xpos, ypos, line):
y_pos = y - (idx*lineheight)
gfx_x = x

num_items = str(len(line))
num_items = str(len(line)) if hasattr(line, '__len__') else '1'
kind_of_item = type(line).__name__

tx, _ = draw_text(color, gfx_x, y_pos, f"{kind_of_item} of {num_items} items")
gfx_x += (tx + 5)

content_dict = defaultdict(int)
for item in line:
content_dict[type(item).__name__] += 1
if hasattr(line, '__iter__'):
for item in line:
content_dict[type(item).__name__] += 1
else:
content_dict[type(line).__name__] += 1

tx, _ = draw_text(color, gfx_x, y_pos, str(dict(content_dict)))
gfx_x += (tx + 5)

0 comments on commit 95a22d8

Please sign in to comment.