From 8a294e4134c0afb9dbf2e0c29c21207a05017d1a Mon Sep 17 00:00:00 2001 From: Ian Leeder Date: Fri, 7 Aug 2020 01:29:45 +1000 Subject: [PATCH] Clean up ALLOWED_CHARS (#1235) --- esphome/config_validation.py | 8 +++----- esphome/wizard.py | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/esphome/config_validation.py b/esphome/config_validation.py index 9862a52c3e..3fb2b4827c 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -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', diff --git a/esphome/wizard.py b/esphome/wizard.py index 97c45c9e1a..3ec6c9fd10 100644 --- a/esphome/wizard.py +++ b/esphome/wizard.py @@ -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)