Add support for dynamic frontend panels
This commit is contained in:
parent
35a57e1385
commit
22b4aebeb3
21 changed files with 197 additions and 119 deletions
37
script/fingerprint_frontend.py
Executable file
37
script/fingerprint_frontend.py
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from collections import OrderedDict
|
||||
import glob
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
fingerprint_file = 'homeassistant/components/frontend/version.py'
|
||||
base_dir = 'homeassistant/components/frontend/www_static/'
|
||||
|
||||
|
||||
def fingerprint():
|
||||
"""Fingerprint the frontend files."""
|
||||
files = (glob.glob(base_dir + '**/*.html') +
|
||||
glob.glob(base_dir + '*.html') +
|
||||
glob.glob(base_dir + 'core.js'))
|
||||
|
||||
md5s = OrderedDict()
|
||||
|
||||
for fil in sorted(files):
|
||||
name = fil[len(base_dir):]
|
||||
with open(fil) as fp:
|
||||
md5 = hashlib.md5(fp.read().encode('utf-8')).hexdigest()
|
||||
md5s[name] = md5
|
||||
|
||||
template = """\"\"\"DO NOT MODIFY. Auto-generated by script/fingerprint_frontend.\"\"\"
|
||||
|
||||
FINGERPRINTS = {}
|
||||
"""
|
||||
|
||||
result = template.format(json.dumps(md5s, indent=4))
|
||||
|
||||
with open(fingerprint_file, 'w') as fp:
|
||||
fp.write(result)
|
||||
|
||||
if __name__ == '__main__':
|
||||
fingerprint()
|
Loading…
Add table
Add a link
Reference in a new issue