MCPcopy Create free account
hub / github.com/FastLED/FastLED / TypeStats

Class TypeStats

ci/util/symbol_analysis.py:86–113  ·  view source on GitHub ↗

Statistics for symbol types with dictionary-like functionality

Source from the content-addressed store, hash-verified

84
85@dataclass
86class TypeStats:
87 """Statistics for symbol types with dictionary-like functionality"""
88
89 stats: dict[str, TypeBreakdown] = field(default_factory=lambda: {})
90
91 def add_symbol(self, symbol: SymbolInfo) -> None:
92 """Add a symbol to the type statistics"""
93 sym_type = symbol.type
94 if sym_type not in self.stats:
95 self.stats[sym_type] = TypeBreakdown(type=sym_type, count=0, total_size=0)
96 self.stats[sym_type].count += 1
97 self.stats[sym_type].total_size += symbol.size
98
99 def items(self) -> list[tuple[str, TypeBreakdown]]:
100 """Return items for iteration, sorted by total_size descending"""
101 return sorted(self.stats.items(), key=lambda x: x[1].total_size, reverse=True)
102
103 def values(self) -> list[TypeBreakdown]:
104 """Return values for iteration"""
105 return list(self.stats.values())
106
107 def __getitem__(self, key: str) -> TypeBreakdown:
108 """Allow dictionary-style access"""
109 return self.stats[key]
110
111 def __contains__(self, key: str) -> bool:
112 """Allow 'in' operator"""
113 return key in self.stats
114
115
116def run_command(cmd: str) -> str:

Callers 1

generate_reportFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected