Update HACS

This commit is contained in:
root
2022-07-10 15:44:36 -07:00
parent ac8cf8f906
commit bb67b3d22b
153 changed files with 67 additions and 11959 deletions

View File

@@ -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"),