mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-10-08 15:27:24 +00:00
.github
config
automation
custom_components
hacs
.translations
hacsbase
handler
helpers
download.py
filters.py
get_defaults.py
information.py
install.py
misc.py
network.py
register_repository.py
validate_repository.py
repositories
__init__.py
config_flow.py
configuration_schema.py
const.py
constrains.py
globals.py
http.py
iconset.js
manifest.json
sensor.py
services.yaml
setup.py
store.py
ws_api_handlers.py
README.md
customize
device_tracker
group
input_boolean
json_data
packages
panels
scene
script
sensor
shell_command
shell_scripts
sounds
switch
templates
www
.HA_VERSION
README.md
configuration.yaml
logger.yaml
recorder.yaml
travis_secrets.yaml
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
_Navigation_NOTICE_.md
31 lines
994 B
Python
31 lines
994 B
Python
"""Helper functions: misc"""
|
|
import semantic_version
|
|
|
|
|
|
def get_repository_name(repository) -> str:
|
|
"""Return the name of the repository for use in the frontend."""
|
|
|
|
if repository.repository_manifest.name is not None:
|
|
return repository.repository_manifest.name
|
|
|
|
if repository.data.category == "integration":
|
|
if repository.integration_manifest:
|
|
if "name" in repository.integration_manifest:
|
|
return repository.integration_manifest["name"]
|
|
|
|
return (
|
|
repository.data.full_name.split("/")[-1]
|
|
.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)
|