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

Lint the script folder files (#5991)

This commit is contained in:
Jesse Hills
2023-12-22 20:03:47 +13:00
committed by GitHub
parent 676ae6b26e
commit d2d0058386
6 changed files with 398 additions and 377 deletions

View File

@@ -2,7 +2,6 @@
import argparse
import re
import subprocess
from dataclasses import dataclass
import sys
@@ -40,12 +39,12 @@ class Version:
def sub(path, pattern, repl, expected_count=1):
with open(path) as fh:
with open(path, encoding="utf-8") as fh:
content = fh.read()
content, count = re.subn(pattern, repl, content, flags=re.MULTILINE)
if expected_count is not None:
assert count == expected_count, f"Pattern {pattern} replacement failed!"
with open(path, "w") as fh:
with open(path, "w", encoding="utf-8") as fh:
fh.write(content)