* Bump min version for latest to use async/await * Use async functions * Load async support for es5 * Lint
32 lines
909 B
Python
32 lines
909 B
Python
"""Frontend for Home Assistant."""
|
|
import os
|
|
from user_agents import parse
|
|
|
|
FAMILY_MIN_VERSION = {
|
|
'Chrome': 55, # Async/await
|
|
'Chrome Mobile': 55,
|
|
'Firefox': 52, # Async/await
|
|
'Firefox Mobile': 52,
|
|
'Opera': 42, # Async/await
|
|
'Edge': 15, # Async/await
|
|
'Safari': 10.1, # Async/await
|
|
}
|
|
|
|
|
|
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
|