MCPcopy
hub / github.com/666ghj/BettaFish / count_charts

Function count_charts

regenerate_latest_pdf.py:66–77  ·  view source on GitHub ↗

递归统计 block 列表中的 Chart.js 图表数量

(blocks)

Source from the content-addressed store, hash-verified

64 chapters = document_ir.get('chapters', [])
65
66 def count_charts(blocks):
67 """递归统计 block 列表中的 Chart.js 图表数量"""
68 count = 0
69 for block in blocks:
70 if isinstance(block, dict):
71 if block.get('type') == 'widget' and block.get('widgetType', '').startswith('chart.js'):
72 count += 1
73 # 递归处理嵌套blocks
74 nested = block.get('blocks')
75 if isinstance(nested, list):
76 count += count_charts(nested)
77 return count
78
79 for chapter in chapters:
80 blocks = chapter.get('blocks', [])

Callers 1

load_document_irFunction · 0.70

Calls 1

getMethod · 0.45

Tested by

no test coverage detected