mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-08-18 03:15:45 +00:00
Finally got around to installing This amazing component by @ludeeus
This commit is contained in:
27
config/custom_components/hacs/helpers/misc.py
Executable file
27
config/custom_components/hacs/helpers/misc.py
Executable file
@@ -0,0 +1,27 @@
|
||||
"""Helper functions: misc"""
|
||||
import semantic_version
|
||||
|
||||
|
||||
def get_repository_name(
|
||||
hacs_manifest, repository_name: str, category: str = None, manifest: dict = None
|
||||
) -> str:
|
||||
"""Return the name of the repository for use in the frontend."""
|
||||
|
||||
if hacs_manifest.name is not None:
|
||||
return hacs_manifest.name
|
||||
|
||||
if category == "integration":
|
||||
if manifest:
|
||||
if "name" in manifest:
|
||||
return manifest["name"]
|
||||
|
||||
return repository_name.replace("-", " ").replace("_", " ").title()
|
||||
|
||||
|
||||
def version_left_higher_then_right(new: str, old: str) -> bool:
|
||||
"""Return a bool if source is newer than target, will also be true if identical."""
|
||||
if not isinstance(new, str) or not isinstance(old, str):
|
||||
return False
|
||||
if new == old:
|
||||
return True
|
||||
return semantic_version.Version.coerce(new) > semantic_version.Version.coerce(old)
|
Reference in New Issue
Block a user