mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-06 09:29:31 +00:00
* Add new data Layer for addons * draft v2 * part 3 * Cleanups for new addon layout * cleanup part 5 * fix lint p1 * fix lint p2 * fix api bug * Fix lint p3 * fix lint p4 * fix lint p5 * fix lint p6 * fix update * fix lint * Update repo add code part 1 * new repository load code * reorder code * Code cleanup p1 * Don't allow change options for not installed addons * Cleanup error handling * Fix addon restart config bug * minimize timeout for bad addons * set core timeout for docker to 15 * fix lint * fix start bug * Add startuptype * change names / fix update bug * fix update bug p2 * Cleanup arch * Ignore built-in repositories * fix lint * fix bug * fix bug p4 * fix arch handling / better bugfix for boot option * fix lint * fix arch * fix options * fix close is no coro * update api description & fix lint * Fix error * fix api validate config * cleanup api * Fix repo loader * cleanup slugs * fix lint
22 lines
500 B
Python
22 lines
500 B
Python
"""Util addons functions."""
|
|
import hashlib
|
|
import re
|
|
|
|
RE_SLUGIFY = re.compile(r'[^a-z0-9_]+')
|
|
RE_SHA1 = re.compile(r"[a-f0-9]{8}")
|
|
|
|
|
|
def get_hash_from_repository(name):
|
|
"""Generate a hash from repository."""
|
|
key = name.lower().encode()
|
|
return hashlib.sha1(key).hexdigest()[:8]
|
|
|
|
|
|
def extract_hash_from_path(path):
|
|
"""Extract repo id from path."""
|
|
repo_dir = path.parts[-1]
|
|
|
|
if not RE_SHA1.match(repo_dir):
|
|
return get_hash_from_repository(repo_dir)
|
|
return repo_dir
|