mirror of
https://github.com/natekspencer/hacs-oasis_mini.git
synced 2025-12-06 18:44:14 -05:00
Adjust exceptions
This commit is contained in:
@@ -30,29 +30,29 @@ def _bit_to_bool(val: str) -> bool:
|
||||
def _parse_int(val: str) -> int:
|
||||
"""
|
||||
Parse a string into an integer, falling back to 0 when conversion fails.
|
||||
|
||||
|
||||
Parameters:
|
||||
val (str): String potentially containing an integer value.
|
||||
|
||||
|
||||
Returns:
|
||||
int: The parsed integer, or 0 if `val` cannot be converted.
|
||||
"""
|
||||
try:
|
||||
return int(val)
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001
|
||||
return 0
|
||||
|
||||
|
||||
def create_svg(track: dict, progress: int) -> str | None:
|
||||
"""
|
||||
Create an SVG visualization of a track showing progress as a completed path and indicator.
|
||||
|
||||
|
||||
Builds an SVG representation from the track's "svg_content" and the provided progress value. If progress is supplied, the function will decrypt the stored SVG content (if needed), compute which path segments are complete using the track's optional "reduced_svg_content_new" value or the number of path segments, and render a base arc, completed arc, track, completed track segment, background circle, and a ball indicator positioned at the current progress point. Returns None if input is missing or an error occurs.
|
||||
|
||||
|
||||
Parameters:
|
||||
track (dict): Track data containing at minimum an "svg_content" entry and optionally "reduced_svg_content_new" to indicate total segments.
|
||||
progress (int): Current progress expressed as a count relative to the track's total segments.
|
||||
|
||||
|
||||
Returns:
|
||||
str | None: Serialized SVG markup as a UTF-8 string when successful, otherwise `None`.
|
||||
"""
|
||||
@@ -169,8 +169,8 @@ def create_svg(track: dict, progress: int) -> str | None:
|
||||
)
|
||||
|
||||
return tostring(svg).decode()
|
||||
except Exception as e:
|
||||
_LOGGER.exception(e)
|
||||
except Exception:
|
||||
_LOGGER.exception("Error creating svg")
|
||||
return None
|
||||
|
||||
|
||||
@@ -200,4 +200,4 @@ def decrypt_svg_content(svg_content: dict[str, str]):
|
||||
|
||||
|
||||
def now() -> datetime:
|
||||
return datetime.now(UTC)
|
||||
return datetime.now(UTC)
|
||||
|
||||
Reference in New Issue
Block a user