Resolve example name to path, ensuring it exists. Args: example: Example name (e.g., "Blink" or "examples/Blink") Returns: Normalized example name without "examples/" prefix Raises: FileNotFoundError: If example directory does not exist
(example: str)
| 98 | |
| 99 | |
| 100 | def resolve_example_path(example: str) -> str: |
| 101 | """Resolve example name to path, ensuring it exists. |
| 102 | |
| 103 | Args: |
| 104 | example: Example name (e.g., "Blink" or "examples/Blink") |
| 105 | |
| 106 | Returns: |
| 107 | Normalized example name without "examples/" prefix |
| 108 | |
| 109 | Raises: |
| 110 | FileNotFoundError: If example directory does not exist |
| 111 | """ |
| 112 | project_root = _get_project_root() |
| 113 | examples_dir = project_root / "examples" |
| 114 | |
| 115 | # Handle both "Blink" and "examples/Blink" formats |
| 116 | if example.startswith("examples/"): |
| 117 | example = example[len("examples/") :] |
| 118 | |
| 119 | example_path = examples_dir / example |
| 120 | if not example_path.exists(): |
| 121 | raise FileNotFoundError(f"Example not found: {example_path}") |
| 122 | |
| 123 | return example |
| 124 | |
| 125 | |
| 126 | def get_board_artifact_extension(board: Board) -> str: |
no test coverage detected