32 lines
961 B
Python
32 lines
961 B
Python
"""Frontend for Home Assistant."""
|
|
import os
|
|
from user_agents import parse
|
|
|
|
FAMILY_MIN_VERSION = {
|
|
'Chrome': 54, # Object.values
|
|
'Chrome Mobile': 54,
|
|
'Firefox': 47, # Object.values
|
|
'Firefox Mobile': 47,
|
|
'Opera': 41, # Object.values
|
|
'Edge': 14, # Array.prototype.includes added in 14
|
|
'Safari': 10, # Many features not supported by 9
|
|
}
|
|
|
|
|
|
def where():
|
|
"""Return path to the frontend."""
|
|
return os.path.dirname(__file__)
|
|
|
|
|
|
def version(useragent):
|
|
"""Get the version for given user agent."""
|
|
useragent = parse(useragent)
|
|
|
|
# on iOS every browser is a Safari which we support from version 11.
|
|
if useragent.os.family == 'iOS':
|
|
# Was >= 10, temp setting it to 12 to work around issue #11387
|
|
return useragent.os.version[0] >= 12
|
|
|
|
version = FAMILY_MIN_VERSION.get(useragent.browser.family)
|
|
return version and useragent.browser.version[0] >= version
|