diff options
| author | Alberson Miranda <albersonmiranda@hotmail.com> | 2025-12-05 13:27:03 -0300 |
|---|---|---|
| committer | Alberson Miranda <albersonmiranda@hotmail.com> | 2025-12-05 13:27:03 -0300 |
| commit | d3f0b79867deb344c03d50599e589b0a6e9a46f4 (patch) | |
| tree | 3e084f69b6da586f1c4fe0ea250831565c29cea5 /config/hypr/UserScripts | |
| parent | 1788691d242abe607add69d211478e306a154cc6 (diff) | |
fix: Check for empty strings in place parts and prevent coordinates from printing when a place is found.
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/Weather.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index a9a826e1..7da48f1e 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -455,15 +455,15 @@ def fetch_aqi(lat: float, lon: float) -> Optional[Dict[str, Any]]: def extract_place_parts_nominatim(data_dict: JSONDict) -> List[str]: address = ensure_dict(data_dict.get("address")) candidates = [data_dict.get("name"), address.get("city"), address.get("town"), address.get("village"), address.get("hamlet")] - name = cast(Optional[str], next((c for c in candidates if c is not None), None)) + name = cast(Optional[str], next((c for c in candidates if c is not None and c != ""), None)) admin1 = cast(Optional[str], address.get("state")) country = cast(Optional[str], address.get("country")) parts: List[str] = [] - if name is not None: + if name is not None and name != "": parts.append(name) - if admin1 is not None: + if admin1 is not None and admin1 != "": parts.append(admin1) - if country is not None: + if country is not None and country != "": parts.append(country) return parts @@ -691,7 +691,7 @@ def build_aqi_info(aqi: Optional[Dict[str, Any]]) -> str: def build_place_str(lat: float, lon: float, place: Optional[str]) -> str: effective_place = MANUAL_PLACE or ENV_PLACE or place if effective_place: - return f"{effective_place} ({lat:.3f}, {lon:.3f})" + return effective_place return f"{lat:.3f}, {lon:.3f}" |
