Skip to content

Commit

Permalink
Merge pull request #5021 from nortikin/fix_5020_Stethoscope_node_cann…
Browse files Browse the repository at this point in the history
…ot_show_count_of_objects_if_items_are_objects

fix #5020 Stethoscope node cannot show count of objects if items are objects or not iterable
  • Loading branch information
satabol authored Oct 18, 2023
2 parents e4079a0 + 95a22d8 commit 9000821
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
Expand Up @@ -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)
Expand Down

0 comments on commit 9000821

Please sign in to comment.