1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 07:12:21 +01:00

Implement external custom components installing from YAML (#1630)

* Move components import loading to importlib MetaPathFinder and importlib.resources

* Add external_components component

* Fix

* Fix

* fix cv.url return

* fix validate shorthand git

* implement git refresh

* Use finders from sys.path_hooks instead of looking for __init__.py

* use github:// schema

* error handling

* add test

* fix handling git output

* revert file check handling

* fix test

* allow full component path be specified for local

* fix test

* fix path handling

* lint

Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>
This commit is contained in:
Otto Winter
2021-05-07 20:02:17 +02:00
committed by GitHub
parent 2225594ee8
commit 229bf719a2
15 changed files with 451 additions and 192 deletions

View File

@@ -222,7 +222,7 @@ def write_file_if_changed(path: Union[Path, str], text: str):
write_file(path, text)
def copy_file_if_changed(src, dst):
def copy_file_if_changed(src: os.PathLike, dst: os.PathLike) -> None:
import shutil
if file_compare(src, dst):
@@ -240,7 +240,7 @@ def list_starts_with(list_, sub):
return len(sub) <= len(list_) and all(list_[i] == x for i, x in enumerate(sub))
def file_compare(path1, path2):
def file_compare(path1: os.PathLike, path2: os.PathLike) -> bool:
"""Return True if the files path1 and path2 have the same contents."""
import stat