From 9109e3803b139c349d17b9b413b0ff9d5b965b55 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Fri, 28 Apr 2017 01:01:57 +0200 Subject: [PATCH] Use in every case a hash for addon name --- hassio/addons/util.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hassio/addons/util.py b/hassio/addons/util.py index d5223a214..1ee454c0d 100644 --- a/hassio/addons/util.py +++ b/hassio/addons/util.py @@ -2,19 +2,9 @@ import hashlib import pathlib import re -import unicodedata RE_SLUGIFY = re.compile(r'[^a-z0-9_]+') - - -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 +RE_SHA1 = re.compile(r"[a-f0-9]{40}") def get_hash_from_repository(repo): @@ -31,4 +21,8 @@ def extract_hash_from_path(base_path, options_path): for obj in dirlist: if obj != base_dir: 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