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:
@@ -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)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user