mirror of
https://github.com/esphome/esphome.git
synced 2024-12-21 16:27:44 +01:00
Add hyphen to supported name characters (#1223)
Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
parent
3f6f3c14c4
commit
aea2e9a6bb
@ -40,7 +40,7 @@ ALLOW_EXTRA = vol.ALLOW_EXTRA
|
||||
UNDEFINED = vol.UNDEFINED
|
||||
RequiredFieldInvalid = vol.RequiredFieldInvalid
|
||||
|
||||
ALLOWED_NAME_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789_'
|
||||
ALLOWED_NAME_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789_-'
|
||||
|
||||
RESERVED_IDS = [
|
||||
# C++ keywords http://en.cppreference.com/w/cpp/keyword
|
||||
|
@ -10,7 +10,7 @@ ESP_PLATFORM_ESP32 = 'ESP32'
|
||||
ESP_PLATFORM_ESP8266 = 'ESP8266'
|
||||
ESP_PLATFORMS = [ESP_PLATFORM_ESP32, ESP_PLATFORM_ESP8266]
|
||||
|
||||
ALLOWED_NAME_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789_'
|
||||
ALLOWED_NAME_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789_-'
|
||||
# Lookup table from ESP32 arduino framework version to latest platformio
|
||||
# package with that version
|
||||
# See also https://github.com/platformio/platform-espressif32/releases
|
||||
|
@ -359,7 +359,7 @@
|
||||
<p>
|
||||
Names must be all <strong>lowercase</strong> and <strong>must not contain any spaces</strong>!
|
||||
Characters that are allowed are: <code class="inlinecode">a-z</code>,
|
||||
<code class="inlinecode">0-9</code> and <code class="inlinecode">_</code>.
|
||||
<code class="inlinecode">0-9</code>, <code class="inlinecode">_</code> and <code class="inlinecode">-</code>.
|
||||
</p>
|
||||
|
||||
<div class="input-field col s12">
|
||||
|
@ -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)))
|
||||
|
@ -5,7 +5,7 @@ esphome:
|
||||
build_path: build/test4
|
||||
|
||||
substitutions:
|
||||
devicename: test4
|
||||
devicename: test-4
|
||||
|
||||
ethernet:
|
||||
type: LAN8720
|
||||
|
@ -27,7 +27,7 @@ def test_alphanumeric__invalid(value):
|
||||
actual = config_validation.alphanumeric(value)
|
||||
|
||||
|
||||
@given(value=text(alphabet=string.ascii_lowercase + string.digits + "_"))
|
||||
@given(value=text(alphabet=string.ascii_lowercase + string.digits + "_-"))
|
||||
def test_valid_name__valid(value):
|
||||
actual = config_validation.valid_name(value)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user