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

Function get_example_ino_path

ci/compiler/board_example_utils.py:147–190  ·  view source on GitHub ↗

Get the path to the .ino file for an example. Args: example: Example name (e.g., "Blink" or "Fx/FxWave2d") Returns: Path to the .ino file Raises: FileNotFoundError: If .ino file not found or multiple .ino files found

(example: str)

Source from the content-addressed store, hash-verified

145
146
147def get_example_ino_path(example: str) -> Path:
148 """Get the path to the .ino file for an example.
149
150 Args:
151 example: Example name (e.g., "Blink" or "Fx/FxWave2d")
152
153 Returns:
154 Path to the .ino file
155
156 Raises:
157 FileNotFoundError: If .ino file not found or multiple .ino files found
158 """
159 project_root = _get_project_root()
160 examples_dir = project_root / "examples"
161
162 # Handle both "Blink" and "examples/Blink" formats
163 if example.startswith("examples/"):
164 example = example[len("examples/") :]
165
166 # Find the .ino file in the example directory
167 example_dir = examples_dir / example
168 example_name = Path(
169 example
170 ).name # Get just the last part (e.g., "Blink" or "FxWave2d")
171 ino_file = example_dir / f"{example_name}.ino"
172
173 if ino_file.exists():
174 return ino_file
175
176 # If the expected filename doesn't exist, search for any .ino file in the directory
177 if example_dir.exists() and example_dir.is_dir():
178 ino_files = list(example_dir.glob("*.ino"))
179 if len(ino_files) == 1:
180 # Exactly one .ino file found, use it
181 return ino_files[0]
182 elif len(ino_files) > 1:
183 # Multiple .ino files - ambiguous, raise error
184 raise FileNotFoundError(
185 f"Example directory '{example}' contains multiple .ino files: "
186 f"{[f.name for f in ino_files]}. Cannot determine which to use."
187 )
188 # else: no .ino files found, will raise below
189
190 raise FileNotFoundError(f"Example .ino file not found: {ino_file}")
191
192
193def should_skip_example_for_board(board: Board, example: str) -> tuple[bool, str]:

Calls 2

listClass · 0.85
_get_project_rootFunction · 0.70

Tested by 1