mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-14 12:46:32 +00:00
Use in every case a hash for addon name
This commit is contained in:
parent
422dd78489
commit
9109e3803b
@ -2,19 +2,9 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import unicodedata
|
|
||||||
|
|
||||||
RE_SLUGIFY = re.compile(r'[^a-z0-9_]+')
|
RE_SLUGIFY = re.compile(r'[^a-z0-9_]+')
|
||||||
|
RE_SHA1 = re.compile(r"[a-f0-9]{40}")
|
||||||
|
|
||||||
def slugify(text):
|
|
||||||
"""Slugify a given text."""
|
|
||||||
text = unicodedata.normalize('NFKD', text)
|
|
||||||
text = text.lower()
|
|
||||||
text = text.replace(" ", "_")
|
|
||||||
text = RE_SLUGIFY.sub("", text)
|
|
||||||
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
def get_hash_from_repository(repo):
|
def get_hash_from_repository(repo):
|
||||||
@ -31,4 +21,8 @@ def extract_hash_from_path(base_path, options_path):
|
|||||||
for obj in dirlist:
|
for obj in dirlist:
|
||||||
if obj != base_dir:
|
if obj != base_dir:
|
||||||
continue
|
continue
|
||||||
return slugify(next(dirlist))
|
|
||||||
|
repo_dir = next(dirlist)
|
||||||
|
if not RE_SHA1.match(repo_dir):
|
||||||
|
return get_hash_from_repository(repo_dir)
|
||||||
|
return repo_dir
|
||||||
|
Loading…
x
Reference in New Issue
Block a user