1
0
mirror of https://github.com/esphome/esphome.git synced 2025-06-18 06:15:46 +01:00

Synchronise Device Classes from Home Assistant ()

* Synchronise Device Classes from Home Assistant

* Remove count do the `DEVICE_CLASSES` list is also updated

* Format file

---------

Co-authored-by: esphomebot <esphome@nabucasa.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2023-03-29 15:47:00 +13:00
committed by GitHub
parent c4ddf7697d
commit a014d853a4
4 changed files with 14 additions and 4 deletions
esphome
components
const.py
script

@ -25,9 +25,9 @@ DOMAINS = {
def sub(path, pattern, repl):
with open(path, "r") as handle:
with open(path) as handle:
content = handle.read()
content = re.sub(pattern, repl, content, flags=re.MULTILINE, count=1)
content = re.sub(pattern, repl, content, flags=re.MULTILINE)
with open(path, "w") as handle:
handle.write(content)
@ -48,7 +48,7 @@ def main():
out = ""
for cls in sorted(classes):
out += f'DEVICE_CLASS_{cls.upper()} = "{classes[cls]}"\n'
sub("esphome/const.py", '(DEVICE_CLASS_\w+ = "\w*"\r?\n)+', out)
sub("esphome/const.py", '(DEVICE_CLASS_\\w+ = "\\w*"\r?\n)+', out)
for domain in sorted(allowed):
# replace imports
@ -58,7 +58,7 @@ def main():
sub(
f"esphome/components/{domain}/__init__.py",
"( DEVICE_CLASS_\w+,\r?\n)+",
"( DEVICE_CLASS_\\w+,\r?\n)+",
out,
)