Skip to content

Commit 84f3a38

Browse files
committed
fix: log message and helper function
1 parent ad67ff9 commit 84f3a38

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

custom_components/powercalc/power_profile/loader/remote.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def _get_library_model(self, manufacturer: str, model: str) -> LibraryModel:
279279
"""Retrieve model info, or raise an error if not found."""
280280
model_info = self.model_infos.get(f"{manufacturer}/{model}")
281281
if not model_info:
282-
raise LibraryLoadingError("Model not found in library: %s/%s", manufacturer, model)
282+
raise LibraryLoadingError(f"Model not found in library: {manufacturer}/{model}")
283283
return model_info
284284

285285
async def _needs_update(
@@ -424,10 +424,14 @@ def _save_file(data: bytes, directory: str) -> None:
424424
except (TimeoutError, aiohttp.ClientError) as e:
425425
raise ProfileDownloadError(f"Failed to download profile: {manufacturer}/{model}") from e
426426

427+
def _get_profile_hashes_path(self) -> str:
428+
"""Retrieve the local storage path for the profile hashes file."""
429+
return str(self.hass.config.path(STORAGE_DIR, BUILT_IN_LIBRARY_DIR, ".profile_hashes"))
430+
427431
def _load_profile_hashes(self) -> dict[str, str]:
428432
"""Load profile hashes from local storage"""
429433

430-
path = self.hass.config.path(STORAGE_DIR, BUILT_IN_LIBRARY_DIR, ".profile_hashes")
434+
path = self._get_profile_hashes_path()
431435
if not os.path.exists(path):
432436
return {}
433437

@@ -437,6 +441,6 @@ def _load_profile_hashes(self) -> dict[str, str]:
437441
def _write_profile_hashes(self, hashes: dict[str, str]) -> None:
438442
"""Write profile hashes to local storage"""
439443

440-
path = self.hass.config.path(STORAGE_DIR, BUILT_IN_LIBRARY_DIR, ".profile_hashes")
444+
path = self._get_profile_hashes_path()
441445
with open(path, "w") as json_file:
442446
json.dump(hashes, json_file, indent=4)

custom_components/powercalc/strategy/lut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def get_lut_file(power_profile: PowerProfile, lookup_mode: LookupMode) -> TextIO
188188
_LOGGER.debug("Loading LUT data file: %s", path)
189189
return open(path)
190190

191-
raise LutFileNotFoundError("Data file not found: %s")
191+
raise LutFileNotFoundError(f"Data file not found: {path}")
192192

193193

194194
class LutStrategy(PowerCalculationStrategyInterface):

0 commit comments

Comments
 (0)