mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-08-20 20:16:52 +00:00
Updated HACS and also fixed Garadget #727
This commit is contained in:
72
config/custom_components/hacs/repositories/theme.py
Executable file → Normal file
72
config/custom_components/hacs/repositories/theme.py
Executable file → Normal file
@@ -1,23 +1,22 @@
|
||||
"""Class for themes in HACS."""
|
||||
from .repository import HacsRepository, register_repository_class
|
||||
from integrationhelper import Logger
|
||||
from .repository import HacsRepository
|
||||
from ..hacsbase.exceptions import HacsException
|
||||
from ..helpers.filters import filter_content_return_one_of_type, find_first_of_filetype
|
||||
from ..helpers.information import find_file_name
|
||||
|
||||
|
||||
@register_repository_class
|
||||
class HacsTheme(HacsRepository):
|
||||
"""Themes in HACS."""
|
||||
|
||||
category = "theme"
|
||||
|
||||
def __init__(self, full_name):
|
||||
"""Initialize."""
|
||||
super().__init__()
|
||||
self.information.full_name = full_name
|
||||
self.information.category = self.category
|
||||
self.data.full_name = full_name
|
||||
self.data.category = "theme"
|
||||
self.content.path.remote = "themes"
|
||||
self.content.path.local = f"{self.system.config_path}/themes"
|
||||
self.content.path.local = f"{self.hacs.system.config_path}/themes/"
|
||||
self.content.single = False
|
||||
self.logger = Logger(f"hacs.repository.{self.data.category}.{full_name}")
|
||||
|
||||
async def validate_repository(self):
|
||||
"""Validate."""
|
||||
@@ -27,7 +26,6 @@ class HacsTheme(HacsRepository):
|
||||
# Custom step 1: Validate content.
|
||||
compliant = False
|
||||
for treefile in self.treefiles:
|
||||
self.logger.debug(treefile)
|
||||
if treefile.startswith("themes/") and treefile.endswith(".yaml"):
|
||||
compliant = True
|
||||
break
|
||||
@@ -36,25 +34,13 @@ class HacsTheme(HacsRepository):
|
||||
f"Repostitory structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
|
||||
if self.repository_manifest:
|
||||
if self.repository_manifest.content_in_root:
|
||||
self.content.path.remote = ""
|
||||
|
||||
self.content.objects = await self.repository_object.get_contents(
|
||||
self.content.path.remote, self.ref
|
||||
)
|
||||
|
||||
if not isinstance(self.content.objects, list):
|
||||
self.validate.errors.append("Repostitory structure not compliant")
|
||||
|
||||
self.content.files = filter_content_return_one_of_type(
|
||||
self.treefiles, "themes", "yaml"
|
||||
)
|
||||
if self.data.content_in_root:
|
||||
self.content.path.remote = ""
|
||||
|
||||
# Handle potential errors
|
||||
if self.validate.errors:
|
||||
for error in self.validate.errors:
|
||||
if not self.system.status.startup:
|
||||
if not self.hacs.system.status.startup:
|
||||
self.logger.error(error)
|
||||
return self.validate.success
|
||||
|
||||
@@ -67,44 +53,20 @@ class HacsTheme(HacsRepository):
|
||||
await self.common_registration()
|
||||
|
||||
# Set name
|
||||
if self.repository_manifest.filename is not None:
|
||||
self.information.file_name = self.repository_manifest.filename
|
||||
else:
|
||||
self.information.file_name = find_first_of_filetype(
|
||||
self.content.files, "yaml"
|
||||
).split("/")[-1]
|
||||
self.information.name = self.information.file_name.replace(".yaml", "")
|
||||
self.content.path.local = (
|
||||
f"{self.system.config_path}/themes/{self.information.name}"
|
||||
)
|
||||
find_file_name(self)
|
||||
self.content.path.local = f"{self.hacs.system.config_path}/themes/{self.data.file_name.replace('.yaml', '')}"
|
||||
|
||||
async def update_repository(self): # lgtm[py/similar-function]
|
||||
"""Update."""
|
||||
if self.github.ratelimits.remaining == 0:
|
||||
if self.hacs.github.ratelimits.remaining == 0:
|
||||
return
|
||||
# Run common update steps.
|
||||
await self.common_update()
|
||||
|
||||
# Get theme objects.
|
||||
if self.repository_manifest:
|
||||
if self.repository_manifest.content_in_root:
|
||||
self.content.path.remote = ""
|
||||
self.content.objects = await self.repository_object.get_contents(
|
||||
self.content.path.remote, self.ref
|
||||
)
|
||||
|
||||
self.content.files = filter_content_return_one_of_type(
|
||||
self.treefiles, "themes", "yaml"
|
||||
)
|
||||
if self.data.content_in_root:
|
||||
self.content.path.remote = ""
|
||||
|
||||
# Update name
|
||||
if self.repository_manifest.filename is not None:
|
||||
self.information.file_name = self.repository_manifest.filename
|
||||
else:
|
||||
self.information.file_name = find_first_of_filetype(
|
||||
self.content.files, "yaml"
|
||||
).split("/")[-1]
|
||||
self.information.name = self.information.file_name.replace(".yaml", "")
|
||||
self.content.path.local = (
|
||||
f"{self.system.config_path}/themes/{self.information.name}"
|
||||
)
|
||||
find_file_name(self)
|
||||
self.content.path.local = f"{self.hacs.system.config_path}/themes/{self.data.file_name.replace('.yaml', '')}"
|
||||
|
Reference in New Issue
Block a user