Read default_envs from platformio.ini. Args: project_dir: Path to PlatformIO project directory Returns: First default environment name, or None if not found
(project_dir: str)
| 534 | |
| 535 | |
| 536 | def get_default_environment(project_dir: str) -> str | None: |
| 537 | """Read default_envs from platformio.ini. |
| 538 | |
| 539 | Args: |
| 540 | project_dir: Path to PlatformIO project directory |
| 541 | |
| 542 | Returns: |
| 543 | First default environment name, or None if not found |
| 544 | """ |
| 545 | ini_path = Path(project_dir) / "platformio.ini" |
| 546 | if not ini_path.exists(): |
| 547 | return None |
| 548 | |
| 549 | try: |
| 550 | config = configparser.ConfigParser() |
| 551 | config.read(ini_path) |
| 552 | |
| 553 | # Get default_envs from [platformio] section |
| 554 | if config.has_section("platformio") and config.has_option( |
| 555 | "platformio", "default_envs" |
| 556 | ): |
| 557 | default_envs = config.get("platformio", "default_envs") |
| 558 | # Can be comma-separated list, take first one |
| 559 | first_env = default_envs.split(",")[0].strip() |
| 560 | return first_env if first_env else None |
| 561 | |
| 562 | return None |
| 563 | except KeyboardInterrupt as ki: |
| 564 | handle_keyboard_interrupt(ki) |
| 565 | raise |
| 566 | except Exception as e: |
| 567 | logging.warning(f"Failed to read default_envs from platformio.ini: {e}") |
| 568 | return None |
| 569 | |
| 570 | |
| 571 | def process_package_request(request: PackageRequest) -> bool: |
no test coverage detected