Clean up ALLOWED_CHARS (#1235)

This commit is contained in:
Ian Leeder 2020-08-07 01:29:45 +10:00 committed by GitHub
parent aad9a539c1
commit 8a294e4134
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View file

@ -11,9 +11,9 @@ from string import ascii_letters, digits
import voluptuous as vol
from esphome import core
from esphome.const import CONF_AVAILABILITY, CONF_COMMAND_TOPIC, CONF_DISCOVERY, CONF_ID, \
CONF_INTERNAL, CONF_NAME, CONF_PAYLOAD_AVAILABLE, CONF_PAYLOAD_NOT_AVAILABLE, \
CONF_RETAIN, CONF_SETUP_PRIORITY, CONF_STATE_TOPIC, CONF_TOPIC, \
from esphome.const import ALLOWED_NAME_CHARS, CONF_AVAILABILITY, CONF_COMMAND_TOPIC, \
CONF_DISCOVERY, CONF_ID, CONF_INTERNAL, CONF_NAME, CONF_PAYLOAD_AVAILABLE, \
CONF_PAYLOAD_NOT_AVAILABLE, CONF_RETAIN, CONF_SETUP_PRIORITY, CONF_STATE_TOPIC, CONF_TOPIC, \
CONF_HOUR, CONF_MINUTE, CONF_SECOND, CONF_VALUE, CONF_UPDATE_INTERVAL, CONF_TYPE_ID, CONF_TYPE
from esphome.core import CORE, HexInt, IPAddress, Lambda, TimePeriod, TimePeriodMicroseconds, \
TimePeriodMilliseconds, TimePeriodSeconds, TimePeriodMinutes
@ -40,8 +40,6 @@ ALLOW_EXTRA = vol.ALLOW_EXTRA
UNDEFINED = vol.UNDEFINED
RequiredFieldInvalid = vol.RequiredFieldInvalid
ALLOWED_NAME_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789_-'
RESERVED_IDS = [
# C++ keywords http://en.cppreference.com/w/cpp/keyword
'alignas', 'alignof', 'and', 'and_eq', 'asm', 'auto', 'bitand', 'bitor', 'bool', 'break',

View file

@ -11,6 +11,7 @@ from esphome.helpers import color, get_bool_env, write_file
from esphome.pins import ESP32_BOARD_PINS, ESP8266_BOARD_PINS
from esphome.storage_json import StorageJSON, ext_storage_path
from esphome.util import safe_print
from esphome.const import ALLOWED_NAME_CHARS
CORE_BIG = r""" _____ ____ _____ ______
/ ____/ __ \| __ \| ____|
@ -172,7 +173,7 @@ def wizard(path):
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)
name = ''.join(c for c in name if c in ALLOWED_NAME_CHARS)
safe_print("Shall I use \"{}\" as the name instead?".format(color('cyan', name)))
sleep(0.5)
name = default_input("(name [{}]): ", name)