2019-04-22 21:56:30 +02:00
|
|
|
import json
|
2019-05-11 11:41:09 +02:00
|
|
|
import os
|
2019-04-22 21:56:30 +02:00
|
|
|
|
2019-10-24 21:53:42 +02:00
|
|
|
from esphome.core import CORE
|
|
|
|
from esphome.helpers import read_file
|
2019-04-22 21:56:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
def read_config_file(path):
|
2019-12-07 18:28:55 +01:00
|
|
|
# type: (str) -> str
|
2021-03-07 20:03:16 +01:00
|
|
|
if CORE.vscode and (
|
|
|
|
not CORE.ace or os.path.abspath(path) == os.path.abspath(CORE.config_path)
|
|
|
|
):
|
|
|
|
print(
|
|
|
|
json.dumps(
|
|
|
|
{
|
|
|
|
"type": "read_file",
|
|
|
|
"path": path,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
2019-12-07 18:28:55 +01:00
|
|
|
data = json.loads(input())
|
2021-03-07 20:03:16 +01:00
|
|
|
assert data["type"] == "file_response"
|
|
|
|
return data["content"]
|
2019-04-22 21:56:30 +02:00
|
|
|
|
2019-10-24 21:53:42 +02:00
|
|
|
return read_file(path)
|