[esp32] Support all IDF component version operators in shorthand syntax (#12499)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import itertools
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
|
||||||
from esphome import yaml_util
|
from esphome import yaml_util
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
@@ -616,10 +617,13 @@ def require_vfs_dir() -> None:
|
|||||||
|
|
||||||
def _parse_idf_component(value: str) -> ConfigType:
|
def _parse_idf_component(value: str) -> ConfigType:
|
||||||
"""Parse IDF component shorthand syntax like 'owner/component^version'"""
|
"""Parse IDF component shorthand syntax like 'owner/component^version'"""
|
||||||
if "^" not in value:
|
# Match operator followed by version-like string (digit or *)
|
||||||
raise cv.Invalid(f"Invalid IDF component shorthand '{value}'")
|
if match := re.search(r"(~=|>=|<=|==|!=|>|<|\^|~)(\d|\*)", value):
|
||||||
name, ref = value.split("^", 1)
|
return {CONF_NAME: value[: match.start()], CONF_REF: value[match.start() :]}
|
||||||
return {CONF_NAME: name, CONF_REF: ref}
|
raise cv.Invalid(
|
||||||
|
f"Invalid IDF component shorthand '{value}'. "
|
||||||
|
f"Expected format: 'owner/component<op>version' where <op> is one of: ^, ~, ~=, ==, !=, >=, >, <=, <"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _validate_idf_component(config: ConfigType) -> ConfigType:
|
def _validate_idf_component(config: ConfigType) -> ConfigType:
|
||||||
|
|||||||
Reference in New Issue
Block a user