mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Revert removal of JSON validator in hassfest (#34504)
Co-Authored-By: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
867138ebb8
commit
ca08b70984
@ -9,6 +9,7 @@ from . import (
|
|||||||
config_flow,
|
config_flow,
|
||||||
coverage,
|
coverage,
|
||||||
dependencies,
|
dependencies,
|
||||||
|
json,
|
||||||
manifest,
|
manifest,
|
||||||
services,
|
services,
|
||||||
ssdp,
|
ssdp,
|
||||||
@ -18,6 +19,7 @@ from . import (
|
|||||||
from .model import Config, Integration
|
from .model import Config, Integration
|
||||||
|
|
||||||
INTEGRATION_PLUGINS = [
|
INTEGRATION_PLUGINS = [
|
||||||
|
json,
|
||||||
codeowners,
|
codeowners,
|
||||||
config_flow,
|
config_flow,
|
||||||
dependencies,
|
dependencies,
|
||||||
|
32
script/hassfest/json.py
Normal file
32
script/hassfest/json.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
"""Validate integration JSON files."""
|
||||||
|
import json
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
from .model import Integration
|
||||||
|
|
||||||
|
|
||||||
|
def validate_json_files(integration: Integration):
|
||||||
|
"""Validate JSON files for integration."""
|
||||||
|
for json_file in integration.path.glob("**/*.json"):
|
||||||
|
if not json_file.is_file():
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
json.loads(json_file.read_text())
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
relative_path = json_file.relative_to(integration.path)
|
||||||
|
integration.add_error("json", f"Invalid JSON file {relative_path}")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def validate(integrations: Dict[str, Integration], config):
|
||||||
|
"""Handle JSON files inside integrations."""
|
||||||
|
if not config.specific_integrations:
|
||||||
|
return
|
||||||
|
|
||||||
|
for integration in integrations.values():
|
||||||
|
if not integration.manifest:
|
||||||
|
continue
|
||||||
|
|
||||||
|
validate_json_files(integration)
|
Loading…
x
Reference in New Issue
Block a user