Finally got around to installing This amazing component by @ludeeus

This commit is contained in:
ccostan
2020-02-13 21:52:51 -05:00
parent eed7d54bf2
commit 3b8847acd9
55 changed files with 7396 additions and 0 deletions

View 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)