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

Function validate_output_path

ci/compiler/output_utils.py:26–66  ·  view source on GitHub ↗

Validate output path and return a result with is_valid, resolved_path, error_message. Args: output_path: The user-specified output path sketch_name: Name of the sketch being built board: Board configuration Returns: ValidateOutputPathResult with is_valid, re

(
    output_path: str, sketch_name: str, board: Board
)

Source from the content-addressed store, hash-verified

24
25
26def validate_output_path(
27 output_path: str, sketch_name: str, board: Board
28) -> ValidateOutputPathResult:
29 """Validate output path and return a result with is_valid, resolved_path, error_message.
30
31 Args:
32 output_path: The user-specified output path
33 sketch_name: Name of the sketch being built
34 board: Board configuration
35
36 Returns:
37 ValidateOutputPathResult with is_valid, resolved_path, and error_message fields
38 """
39 import os
40
41 expected_ext = get_board_artifact_extension(board)
42
43 # Handle special case: -o .
44 if output_path == ".":
45 resolved_path = f"{sketch_name}{expected_ext}"
46 return ValidateOutputPathResult(True, resolved_path, "")
47
48 # If path ends with /, it's a directory
49 if output_path.endswith("/") or output_path.endswith("\\"):
50 resolved_path = os.path.join(output_path, f"{sketch_name}{expected_ext}")
51 return ValidateOutputPathResult(True, resolved_path, "")
52
53 # If path has an extension, it's a file - validate the extension
54 if "." in os.path.basename(output_path):
55 _, ext = os.path.splitext(output_path)
56 if ext != expected_ext:
57 return ValidateOutputPathResult(
58 False,
59 "",
60 f"Output file extension '{ext}' doesn't match expected '{expected_ext}' for board '{board.board_name}'",
61 )
62 return ValidateOutputPathResult(True, output_path, "")
63
64 # Path doesn't end with / and has no extension - treat as directory
65 resolved_path = os.path.join(output_path, f"{sketch_name}{expected_ext}")
66 return ValidateOutputPathResult(True, resolved_path, "")
67
68
69def validate_esp32_flash_mode_for_qemu(build_dir: Path, board: Board) -> bool:

Callers 1

mainFunction · 0.90

Calls 2

Tested by

no test coverage detected