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

Function chunk_sources

ci/wasm_unity_generator.py:65–90  ·  view source on GitHub ↗

Split sources into roughly equal chunks. Args: sources: List of source file paths num_chunks: Number of unity chunks to create Returns: List of lists, where each sublist is a chunk of sources

(sources: list[Path], num_chunks: int)

Source from the content-addressed store, hash-verified

63
64
65def chunk_sources(sources: list[Path], num_chunks: int) -> list[list[Path]]:
66 """
67 Split sources into roughly equal chunks.
68
69 Args:
70 sources: List of source file paths
71 num_chunks: Number of unity chunks to create
72
73 Returns:
74 List of lists, where each sublist is a chunk of sources
75 """
76 if num_chunks <= 0:
77 raise ValueError(f"num_chunks must be > 0, got {num_chunks}")
78
79 if num_chunks > len(sources):
80 num_chunks = len(sources)
81
82 chunk_size = (len(sources) + num_chunks - 1) // num_chunks # Ceiling division
83
84 chunks: list[list[Path]] = []
85 for i in range(0, len(sources), chunk_size):
86 chunk = sources[i : i + chunk_size]
87 if chunk: # Only add non-empty chunks
88 chunks.append(chunk)
89
90 return chunks
91
92
93def generate_unity_file(

Callers 2

generate_unity_buildsFunction · 0.85
list_unity_groupsFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected