refactor(modules): improve exception handling and simplify service usage
Enhancements - Replace bare `except:` with `except Exception:` in multiple modules- Cast step calculation to `int` for consistent type - Simplify `get_battery_icon_file` to return a string directly - Use `get_todo_service()` instead of module-level `todo_service` throughout todo widget - Remove unused `"zen": "zen-browser"` mapping entry Bug Fixes - Prevent bare exception swallowing by catching `Exception` explicitly - Ensure proper cleanup of timer IDs and other resources - Delete unused modules/osdd components New Features - None
This commit is contained in:
34 files changed
+682
-519
No files matched your search
@@ -29,7 +29,7 @@ class BookmarkManager:
|
||||
try:
|
||||
parsed = urlparse(url)
|
||||
return f"{parsed.scheme}://{parsed.netloc}/favicon.ico"
|
||||
except:
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
def _extract_domain(self, url: str) -> str:
|
||||
@@ -41,7 +41,7 @@ class BookmarkManager:
|
||||
if domain.startswith("www."):
|
||||
domain = domain[4:]
|
||||
return domain
|
||||
except:
|
||||
except Exception:
|
||||
return url
|
||||
|
||||
def _normalize_url(self, url: str) -> str:
|
||||
@@ -683,7 +683,7 @@ class BookmarksPlugin(PluginBase):
|
||||
if domain.startswith("www."):
|
||||
domain = domain[4:]
|
||||
return domain
|
||||
except:
|
||||
except Exception:
|
||||
return url
|
||||
|
||||
def _open_bookmark(self, url: str):
|
||||
|
||||
@@ -497,7 +497,7 @@ class PasswordPlugin(PluginBase):
|
||||
f"Password '{name}' {action_word} successfully",
|
||||
]
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
print(f"Failed to add password '{name}'")
|
||||
@@ -524,7 +524,7 @@ class PasswordPlugin(PluginBase):
|
||||
f"Password '{name}' removed successfully",
|
||||
]
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
print(f"Failed to remove password '{name}'")
|
||||
@@ -564,7 +564,7 @@ class PasswordPlugin(PluginBase):
|
||||
f"Password for '{name}' copied to clipboard",
|
||||
]
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Clear cache to force refresh
|
||||
|
||||
@@ -314,11 +314,11 @@ class WallpaperPlugin(PluginBase):
|
||||
)
|
||||
return filename
|
||||
|
||||
def _hsl_to_rgb_hex(self, h: float, s: float = 1.0, l: float = 0.5) -> str:
|
||||
def _hsl_to_rgb_hex(self, h: float, s: float = 1.0, l_val: float = 0.5) -> str:
|
||||
"""Convert HSL color value to RGB HEX string."""
|
||||
# colorsys uses HLS, not HSL, and expects values between 0.0 and 1.0
|
||||
hue = h / 360.0
|
||||
r, g, b = colorsys.hls_to_rgb(hue, l, s) # Note the order: H, L, S
|
||||
r, g, b = colorsys.hls_to_rgb(hue, l_val, s) # Note the order: H, L, S
|
||||
r_int, g_int, b_int = int(r * 255), int(g * 255), int(b * 255)
|
||||
return f"#{r_int:02X}{g_int:02X}{b_int:02X}"
|
||||
|
||||
|
||||
Reference in new issue
Block a user