1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-27 07:32:22 +01:00

Add hyphen to supported name characters (#1223)

Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
Ian Leeder
2020-07-30 08:02:34 +10:00
committed by GitHub
parent 3f6f3c14c4
commit aea2e9a6bb
6 changed files with 8 additions and 7 deletions

View File

@@ -168,8 +168,9 @@ def wizard(path):
name = cv.valid_name(name)
break
except vol.Invalid:
safe_print(color("red", "Oh noes, \"{}\" isn't a valid name. Names can only include "
"numbers, lower-case letters and underscores.".format(name)))
safe_print(color("red", f"Oh noes, \"{name}\" isn't a valid name. Names can only "
f"include numbers, lower-case letters, underscores and "
f"hyphens."))
name = strip_accents(name).lower().replace(' ', '_')
name = ''.join(c for c in name if c in cv.ALLOWED_NAME_CHARS)
safe_print("Shall I use \"{}\" as the name instead?".format(color('cyan', name)))