updating to latest
This commit is contained in:
16
custom_components/hacs/helpers/properties/__init__.py
Normal file
16
custom_components/hacs/helpers/properties/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# pylint: disable=missing-class-docstring,missing-module-docstring,missing-function-docstring,no-member
|
||||
from custom_components.hacs.helpers.properties.can_be_installed import (
|
||||
RepositoryPropertyCanBeInstalled,
|
||||
)
|
||||
from custom_components.hacs.helpers.properties.custom import RepositoryPropertyCustom
|
||||
from custom_components.hacs.helpers.properties.pending_update import (
|
||||
RepositoryPropertyPendingUpdate,
|
||||
)
|
||||
|
||||
|
||||
class RepositoryHelperProperties(
|
||||
RepositoryPropertyPendingUpdate,
|
||||
RepositoryPropertyCustom,
|
||||
RepositoryPropertyCanBeInstalled,
|
||||
):
|
||||
pass
|
||||
@@ -0,0 +1,21 @@
|
||||
# pylint: disable=missing-class-docstring,missing-module-docstring,missing-function-docstring,no-member
|
||||
from abc import ABC
|
||||
|
||||
from custom_components.hacs.helpers.functions.misc import version_left_higher_then_right
|
||||
|
||||
|
||||
class RepositoryPropertyCanBeInstalled(ABC):
|
||||
@property
|
||||
def can_be_installed(self) -> bool:
|
||||
if self.data.homeassistant is not None:
|
||||
if self.data.releases:
|
||||
if not version_left_higher_then_right(
|
||||
self.hacs.core.ha_version, self.data.homeassistant
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
@property
|
||||
def can_install(self):
|
||||
"""kept for legacy compatibility"""
|
||||
return self.can_be_installed
|
||||
13
custom_components/hacs/helpers/properties/custom.py
Normal file
13
custom_components/hacs/helpers/properties/custom.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# pylint: disable=missing-class-docstring,missing-module-docstring,missing-function-docstring,no-member
|
||||
from abc import ABC
|
||||
|
||||
|
||||
class RepositoryPropertyCustom(ABC):
|
||||
@property
|
||||
def custom(self):
|
||||
"""Return flag if the repository is custom."""
|
||||
if str(self.data.id) in self.hacs.common.default:
|
||||
return False
|
||||
if self.data.full_name == "hacs/integration":
|
||||
return False
|
||||
return True
|
||||
23
custom_components/hacs/helpers/properties/pending_update.py
Normal file
23
custom_components/hacs/helpers/properties/pending_update.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# pylint: disable=missing-class-docstring,missing-module-docstring,missing-function-docstring,no-member
|
||||
from abc import ABC
|
||||
|
||||
|
||||
class RepositoryPropertyPendingUpdate(ABC):
|
||||
@property
|
||||
def pending_update(self) -> bool:
|
||||
if not self.can_install:
|
||||
return False
|
||||
if self.data.installed:
|
||||
if self.data.selected_tag is not None:
|
||||
if self.data.selected_tag == self.data.default_branch:
|
||||
if self.data.installed_commit != self.data.last_commit:
|
||||
return True
|
||||
return False
|
||||
if self.display_installed_version != self.display_available_version:
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def pending_upgrade(self) -> bool:
|
||||
"""kept for legacy compatibility"""
|
||||
return self.pending_update
|
||||
Reference in New Issue
Block a user