Create a formatter that maps lib/FastLED paths to src/ and src/sketch paths to examples/{example}/ and timestamps lines. Args: example: Example name or path (e.g., "Pintest" or "examples/SmartMatrix"). Returns: OutputFormatter: Configured formatter instance.
(example: str)
| 189 | |
| 190 | |
| 191 | def create_sketch_path_formatter(example: str) -> OutputFormatter: |
| 192 | """Create a formatter that maps lib/FastLED paths to src/ and src/sketch paths to examples/{example}/ and timestamps lines. |
| 193 | |
| 194 | Args: |
| 195 | example: Example name or path (e.g., "Pintest" or "examples/SmartMatrix"). |
| 196 | |
| 197 | Returns: |
| 198 | OutputFormatter: Configured formatter instance. |
| 199 | """ |
| 200 | # Normalize example path |
| 201 | display_example_str: str |
| 202 | if "/" in example or "\\" in example: |
| 203 | display_example_str = example.replace("\\", "/") |
| 204 | else: |
| 205 | display_example_str = f"examples/{example}" |
| 206 | |
| 207 | # Define multiple path substitutions |
| 208 | substitutions = [ |
| 209 | # Replace lib/FastLED/ paths with src/ for better UX |
| 210 | ("lib/FastLED", r"lib[/\\]+FastLED[/\\]+", "src/"), |
| 211 | # Replace src/sketch/ paths with examples/{example}/ |
| 212 | ("sketch", r"src[/\\]+sketch[/\\]+", f"{display_example_str}/"), |
| 213 | ] |
| 214 | |
| 215 | return _MultiPathSubstitutionFormatter(substitutions) |
no test coverage detected