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

Consistently format errors in CI scripts ()

This commit is contained in:
Oxan van Leeuwen
2021-11-25 21:54:11 +01:00
committed by GitHub
parent 9681dfb458
commit 00965fe19e
8 changed files with 57 additions and 55 deletions

@ -1,4 +1,4 @@
import codecs
import colorama
import os.path
import re
import subprocess
@ -11,13 +11,18 @@ temp_folder = os.path.join(root_path, ".temp")
temp_header_file = os.path.join(temp_folder, "all-include.cpp")
def shlex_quote(s):
if not s:
return "''"
if re.search(r"[^\w@%+=:,./-]", s) is None:
return s
def styled(color, msg, reset=True):
prefix = ''.join(color) if isinstance(color, tuple) else color
suffix = colorama.Style.RESET_ALL if reset else ''
return prefix + msg + suffix
return "'" + s.replace("'", "'\"'\"'") + "'"
def print_error_for_file(file, body):
print(styled(colorama.Fore.GREEN, "### File ") + styled((colorama.Fore.GREEN, colorama.Style.BRIGHT), file))
print()
if body is not None:
print(body)
print()
def build_all_include():