Update HACS
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -40,11 +40,11 @@ class HacsAppdaemonRepository(HacsRepository):
|
||||
addir = await self.repository_object.get_contents("apps", self.ref)
|
||||
except AIOGitHubAPIException:
|
||||
raise HacsException(
|
||||
f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
f"{self.string} Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
) from None
|
||||
|
||||
if not isinstance(addir, list):
|
||||
self.validate.errors.append("Repository structure not compliant")
|
||||
self.validate.errors.append(f"{self.string} Repository structure not compliant")
|
||||
|
||||
self.content.path.remote = addir[0].path
|
||||
self.content.objects = await self.repository_object.get_contents(
|
||||
|
||||
@@ -3,12 +3,11 @@ from __future__ import annotations
|
||||
|
||||
from asyncio import sleep
|
||||
from datetime import datetime
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import tempfile
|
||||
from typing import TYPE_CHECKING, Any, List
|
||||
from typing import TYPE_CHECKING, Any
|
||||
import zipfile
|
||||
|
||||
from aiogithubapi import (
|
||||
@@ -33,7 +32,8 @@ from ..utils.backup import Backup, BackupNetDaemon
|
||||
from ..utils.decode import decode_content
|
||||
from ..utils.decorator import concurrent
|
||||
from ..utils.filters import filter_content_return_one_of_type
|
||||
from ..utils.logger import get_hacs_logger
|
||||
from ..utils.json import json_loads
|
||||
from ..utils.logger import LOGGER
|
||||
from ..utils.path import is_safe
|
||||
from ..utils.queue_manager import QueueManager
|
||||
from ..utils.store import async_remove_store
|
||||
@@ -95,7 +95,7 @@ class RepositoryData:
|
||||
"""RepositoryData class."""
|
||||
|
||||
archived: bool = False
|
||||
authors: List[str] = []
|
||||
authors: list[str] = []
|
||||
category: str = ""
|
||||
config_flow: bool = False
|
||||
default_branch: str = None
|
||||
@@ -119,13 +119,13 @@ class RepositoryData:
|
||||
manifest_name: str = None
|
||||
new: bool = True
|
||||
open_issues: int = 0
|
||||
published_tags: List[str] = []
|
||||
published_tags: list[str] = []
|
||||
pushed_at: str = ""
|
||||
releases: bool = False
|
||||
selected_tag: str = None
|
||||
show_beta: bool = False
|
||||
stargazers_count: int = 0
|
||||
topics: List[str] = []
|
||||
topics: list[str] = []
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -180,7 +180,7 @@ class HacsManifest:
|
||||
"""HacsManifest class."""
|
||||
|
||||
content_in_root: bool = False
|
||||
country: List[str] = []
|
||||
country: list[str] = []
|
||||
filename: str = None
|
||||
hacs: str = None # Minimum HACS version
|
||||
hide_default_branch: bool = False
|
||||
@@ -265,7 +265,7 @@ class HacsRepository:
|
||||
self.tree = []
|
||||
self.treefiles = []
|
||||
self.ref = None
|
||||
self.logger = get_hacs_logger()
|
||||
self.logger = LOGGER
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Return a string representation of the repository."""
|
||||
@@ -319,18 +319,6 @@ class HacsRepository:
|
||||
status = "default"
|
||||
return status
|
||||
|
||||
@property
|
||||
def display_status_description(self) -> str:
|
||||
"""Return display_status_description."""
|
||||
description = {
|
||||
"default": "Not installed.",
|
||||
"pending-restart": "Restart pending.",
|
||||
"pending-upgrade": "Upgrade pending.",
|
||||
"installed": "No action required.",
|
||||
"new": "This is a newly added repository.",
|
||||
}
|
||||
return description[self.display_status]
|
||||
|
||||
@property
|
||||
def display_installed_version(self) -> str:
|
||||
"""Return display_authors"""
|
||||
@@ -364,18 +352,6 @@ class HacsRepository:
|
||||
version_or_commit = "commit"
|
||||
return version_or_commit
|
||||
|
||||
@property
|
||||
def main_action(self) -> str:
|
||||
"""Return the main action."""
|
||||
actions = {
|
||||
"new": "INSTALL",
|
||||
"default": "INSTALL",
|
||||
"installed": "REINSTALL",
|
||||
"pending-restart": "REINSTALL",
|
||||
"pending-upgrade": "UPGRADE",
|
||||
}
|
||||
return actions[self.display_status]
|
||||
|
||||
@property
|
||||
def pending_update(self) -> bool:
|
||||
"""Return True if pending update."""
|
||||
@@ -669,7 +645,7 @@ class HacsRepository:
|
||||
**{"params": {"ref": ref or self.version_to_download()}},
|
||||
)
|
||||
if response:
|
||||
return json.loads(decode_content(response.data.content))
|
||||
return json_loads(decode_content(response.data.content))
|
||||
except BaseException: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
pass
|
||||
|
||||
@@ -705,6 +681,7 @@ class HacsRepository:
|
||||
)
|
||||
if response:
|
||||
return render_template(
|
||||
self.hacs,
|
||||
decode_content(response.data.content)
|
||||
.replace("<svg", "<disabled")
|
||||
.replace("</svg", "</disabled"),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Class for integrations in HACS."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from homeassistant.loader import async_get_custom_components
|
||||
@@ -11,6 +10,7 @@ from ..exceptions import AddonRepositoryException, HacsException
|
||||
from ..utils.decode import decode_content
|
||||
from ..utils.decorator import concurrent
|
||||
from ..utils.filters import get_first_directory_in_directory
|
||||
from ..utils.json import json_loads
|
||||
from .base import HacsRepository
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -62,7 +62,7 @@ class HacsIntegrationRepository(HacsRepository):
|
||||
):
|
||||
raise AddonRepositoryException()
|
||||
raise HacsException(
|
||||
f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
f"{self.string} Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
self.content.path.remote = f"custom_components/{name}"
|
||||
|
||||
@@ -163,4 +163,4 @@ class HacsIntegrationRepository(HacsRepository):
|
||||
**{"params": {"ref": ref or self.version_to_download()}},
|
||||
)
|
||||
if response:
|
||||
return json.loads(decode_content(response.data.content))
|
||||
return json_loads(decode_content(response.data.content))
|
||||
|
||||
@@ -52,7 +52,7 @@ class HacsNetdaemonRepository(HacsRepository):
|
||||
break
|
||||
if not compliant:
|
||||
raise HacsException(
|
||||
f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
f"{self.string} Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
|
||||
# Handle potential errors
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"""Class for plugins in HACS."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ..enums import HacsCategory, HacsDispatchEvent
|
||||
from ..exceptions import HacsException
|
||||
from ..utils.decorator import concurrent
|
||||
from ..utils.json import json_loads
|
||||
from .base import HacsRepository
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -40,7 +40,7 @@ class HacsPluginRepository(HacsRepository):
|
||||
|
||||
if self.content.path.remote is None:
|
||||
raise HacsException(
|
||||
f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
f"{self.string} Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
|
||||
if self.content.path.remote == "release":
|
||||
@@ -64,7 +64,7 @@ class HacsPluginRepository(HacsRepository):
|
||||
|
||||
if self.content.path.remote is None:
|
||||
self.validate.errors.append(
|
||||
f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
f"{self.string} Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
|
||||
if self.content.path.remote == "release":
|
||||
@@ -86,7 +86,7 @@ class HacsPluginRepository(HacsRepository):
|
||||
"""Get package content."""
|
||||
try:
|
||||
package = await self.repository_object.get_contents("package.json", self.ref)
|
||||
package = json.loads(package.content)
|
||||
package = json_loads(package.content)
|
||||
|
||||
if package:
|
||||
self.data.authors = package["author"]
|
||||
@@ -95,10 +95,6 @@ class HacsPluginRepository(HacsRepository):
|
||||
|
||||
def update_filenames(self) -> None:
|
||||
"""Get the filename to target."""
|
||||
possible_locations = (
|
||||
("",) if self.repository_manifest.content_in_root else ("release", "dist", "")
|
||||
)
|
||||
|
||||
# Handler for plug requirement 3
|
||||
if self.repository_manifest.filename:
|
||||
valid_filenames = (self.repository_manifest.filename,)
|
||||
@@ -110,25 +106,25 @@ class HacsPluginRepository(HacsRepository):
|
||||
f"{self.data.name}-bundle.js",
|
||||
)
|
||||
|
||||
for location in possible_locations:
|
||||
if location == "release":
|
||||
if not self.releases.objects:
|
||||
continue
|
||||
if not self.repository_manifest.content_in_root:
|
||||
if self.releases.objects:
|
||||
release = self.releases.objects[0]
|
||||
if not release.assets:
|
||||
continue
|
||||
asset = release.assets[0]
|
||||
for filename in valid_filenames:
|
||||
if filename == asset.name:
|
||||
self.data.file_name = filename
|
||||
self.content.path.remote = "release"
|
||||
break
|
||||
|
||||
else:
|
||||
for filename in valid_filenames:
|
||||
if f"{location+'/' if location else ''}{filename}" in [
|
||||
x.full_path for x in self.tree
|
||||
if release.assets:
|
||||
if assetnames := [
|
||||
filename
|
||||
for filename in valid_filenames
|
||||
for asset in release.assets
|
||||
if filename == asset.name
|
||||
]:
|
||||
self.data.file_name = filename.split("/")[-1]
|
||||
self.content.path.remote = location
|
||||
break
|
||||
self.data.file_name = assetnames[0]
|
||||
self.content.path.remote = "release"
|
||||
return
|
||||
|
||||
for location in ("",) if self.repository_manifest.content_in_root else ("dist", ""):
|
||||
for filename in valid_filenames:
|
||||
if f"{location+'/' if location else ''}{filename}" in [
|
||||
x.full_path for x in self.tree
|
||||
]:
|
||||
self.data.file_name = filename.split("/")[-1]
|
||||
self.content.path.remote = location
|
||||
break
|
||||
|
||||
@@ -48,7 +48,7 @@ class HacsPythonScriptRepository(HacsRepository):
|
||||
break
|
||||
if not compliant:
|
||||
raise HacsException(
|
||||
f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
f"{self.string} Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
|
||||
# Handle potential errors
|
||||
@@ -83,7 +83,7 @@ class HacsPythonScriptRepository(HacsRepository):
|
||||
break
|
||||
if not compliant:
|
||||
raise HacsException(
|
||||
f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
f"{self.string} Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
|
||||
# Update name
|
||||
|
||||
@@ -50,7 +50,7 @@ class HacsThemeRepository(HacsRepository):
|
||||
break
|
||||
if not compliant:
|
||||
raise HacsException(
|
||||
f"Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
f"{self.string} Repository structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
|
||||
if self.repository_manifest.content_in_root:
|
||||
|
||||
Reference in New Issue
Block a user