(match: re.Match[str])
| 462 | pattern = r"\$\{([^}]+)\}" |
| 463 | |
| 464 | def replace_variable(match: re.Match[str]) -> str: |
| 465 | var_ref = match.group(1) |
| 466 | |
| 467 | # Handle section:subsection.option format (like env:generic-esp.build_flags) |
| 468 | if ":" in var_ref: |
| 469 | section_part, option = var_ref.split(".", 1) |
| 470 | section = section_part.replace(":", ":") |
| 471 | else: |
| 472 | # Handle section.option format (like platformio.build_cache_dir) |
| 473 | section, option = var_ref.split(".", 1) |
| 474 | |
| 475 | try: |
| 476 | if config.has_option(section, option): |
| 477 | return config.get(section, option) |
| 478 | else: |
| 479 | # Return original if not found |
| 480 | return match.group(0) |
| 481 | except (configparser.NoSectionError, configparser.NoOptionError): |
| 482 | # Return original if resolution fails |
| 483 | return match.group(0) |
| 484 | |
| 485 | return re.sub(pattern, replace_variable, value) |
| 486 |
nothing calls this directly
no test coverage detected