mirror of
https://github.com/esphome/esphome.git
synced 2025-07-25 12:46:42 +00:00
Use local filesystem for dashboard
This commit is contained in:
parent
cfabba9638
commit
48fb69347d
@ -78,13 +78,23 @@ def _print_file_read_event(path: str) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _loader(fname: str):
|
def _request_and_get_stream_on_stdin(fname: str):
|
||||||
_print_file_read_event(fname)
|
_print_file_read_event(fname)
|
||||||
raw_yaml_stream = StringIO(_read_file_content_from_json_on_stdin())
|
raw_yaml_stream = StringIO(_read_file_content_from_json_on_stdin())
|
||||||
|
return raw_yaml_stream
|
||||||
|
|
||||||
|
|
||||||
|
def _vscode_loader(fname: str):
|
||||||
|
raw_yaml_stream = _request_and_get_stream_on_stdin(fname)
|
||||||
# it is required to set the name on StringIO so document on start_mark
|
# it is required to set the name on StringIO so document on start_mark
|
||||||
# is set properly. Otherwise it is initialized with "<file>"
|
# is set properly. Otherwise it is initialized with "<file>"
|
||||||
raw_yaml_stream.name = fname
|
raw_yaml_stream.name = fname
|
||||||
return parse_yaml(fname, raw_yaml_stream, _loader)
|
return parse_yaml(fname, raw_yaml_stream, _vscode_loader)
|
||||||
|
|
||||||
|
|
||||||
|
def _ace_loader(fname: str):
|
||||||
|
raw_yaml_stream = _request_and_get_stream_on_stdin(fname)
|
||||||
|
return parse_yaml(fname, raw_yaml_stream)
|
||||||
|
|
||||||
|
|
||||||
def read_config(args):
|
def read_config(args):
|
||||||
@ -97,8 +107,10 @@ def read_config(args):
|
|||||||
f = data["file"]
|
f = data["file"]
|
||||||
if CORE.ace:
|
if CORE.ace:
|
||||||
CORE.config_path = os.path.join(args.configuration, f)
|
CORE.config_path = os.path.join(args.configuration, f)
|
||||||
|
loader = _ace_loader
|
||||||
else:
|
else:
|
||||||
CORE.config_path = data["file"]
|
CORE.config_path = data["file"]
|
||||||
|
loader = _vscode_loader
|
||||||
|
|
||||||
file_name = CORE.config_path
|
file_name = CORE.config_path
|
||||||
command_line_substitutions: dict[str, Any] = (
|
command_line_substitutions: dict[str, Any] = (
|
||||||
@ -106,7 +118,7 @@ def read_config(args):
|
|||||||
)
|
)
|
||||||
vs = VSCodeResult()
|
vs = VSCodeResult()
|
||||||
try:
|
try:
|
||||||
config = _loader(file_name)
|
config = loader(file_name)
|
||||||
res = validate_config(config, command_line_substitutions)
|
res = validate_config(config, command_line_substitutions)
|
||||||
except Exception as err: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
vs.add_yaml_error(str(err))
|
vs.add_yaml_error(str(err))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user