mirror of
https://github.com/esphome/esphome.git
synced 2025-06-18 06:15:46 +01:00
Synchronise Device Classes from Home Assistant (#4633)
* 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:
committed by
GitHub
parent
c4ddf7697d
commit
a014d853a4
@ -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,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user