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

Function replace_variable

ci/compiler/platformio_ini.py:464–483  ·  view source on GitHub ↗
(match: re.Match[str])

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

has_optionMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected