1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-09 23:02:23 +01:00

Add cv.require_esphome_version helper (#3103)

This commit is contained in:
Oxan van Leeuwen
2022-01-24 20:10:27 +01:00
committed by GitHub
parent cdda648360
commit 2f46267994
2 changed files with 22 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import typing
from typing import Union, List
import collections
@@ -242,6 +243,13 @@ def is_dev_esphome_version():
return "dev" in const.__version__
def parse_esphome_version() -> typing.Tuple[int, int, int]:
match = re.match(r"^(\d+).(\d+).(\d+)(-dev\d*|b\d*)?$", const.__version__)
if match is None:
raise ValueError(f"Failed to parse ESPHome version '{const.__version__}'")
return int(match.group(1)), int(match.group(2)), int(match.group(3))
# Custom OrderedDict with nicer repr method for debugging
class OrderedDict(collections.OrderedDict):
def __repr__(self):