1- """View Assist Javascript module registration."""
1+ """Task Tracker JavaScript module registration."""
22
33import logging
44import os
55from pathlib import Path
66
77from homeassistant .components .http import StaticPathConfig
88from homeassistant .components .lovelace import MODE_STORAGE , LovelaceData
9- from homeassistant .const import MAJOR_VERSION , MINOR_VERSION
109from homeassistant .core import HomeAssistant
11-
1210from ..const import URL_BASE , TASK_TRACKER_CARDS # noqa: TID252
1311
1412_LOGGER = logging .getLogger (__name__ )
@@ -21,10 +19,10 @@ def __init__(self, hass: HomeAssistant) -> None:
2119 """Initialise."""
2220 self .hass = hass
2321 self .lovelace : LovelaceData = self .hass .data .get ("lovelace" )
24- # Backwards compatability after/before 2026.2
25- if MAJOR_VERSION > 2026 or (MAJOR_VERSION == 2026 and MINOR_VERSION >= 2 ):
22+ if hasattr (self .lovelace , "resource_mode" ):
2623 self .resource_mode = self .lovelace .resource_mode
2724 else :
25+ # Backwards compatibility before 2026.2
2826 self .resource_mode = self .lovelace .mode
2927
3028 async def async_register (self ):
@@ -38,7 +36,7 @@ async def _async_register_path(self):
3836 """Register resource path if not already registered."""
3937 try :
4038 await self .hass .http .async_register_static_paths (
41- [StaticPathConfig (URL_BASE , Path (__file__ ).parent , False )]
39+ [StaticPathConfig (URL_BASE , str ( Path (__file__ ).parent ) , False )]
4240 )
4341 _LOGGER .debug ("Registered resource path from %s" , Path (__file__ ).parent )
4442 except RuntimeError :
@@ -66,7 +64,7 @@ async def _async_register_modules(self):
6664 card_registered = True
6765 # check version
6866 if self ._get_resource_version (resource ["url" ]) != module .get (
69- "version"
67+ "version"
7068 ):
7169 # Update card version
7270 _LOGGER .debug (
@@ -136,10 +134,10 @@ def remove_gzip_files(self):
136134 for file in gzip_files :
137135 try :
138136 if (
139- Path .stat (f"{ path } /{ file } " ).st_mtime
140- < Path .stat (f"{ path } /{ file .replace ('.gz' , '' )} " ).st_mtime
137+ Path .stat (Path ( f"{ path } /{ file } " ) ).st_mtime
138+ < Path .stat (Path ( f"{ path } /{ file .replace ('.gz' , '' )} " ) ).st_mtime
141139 ):
142140 _LOGGER .debug ("Removing older gzip file - %s" , file )
143- Path .unlink (f"{ path } /{ file } " )
141+ Path .unlink (Path ( f"{ path } /{ file } " ) )
144142 except OSError :
145143 pass
0 commit comments