aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts/Weather.py
diff options
context:
space:
mode:
authorAlberson Miranda <albersonmiranda@hotmail.com>2025-12-05 13:27:03 -0300
committerAlberson Miranda <albersonmiranda@hotmail.com>2025-12-05 13:27:03 -0300
commitd3f0b79867deb344c03d50599e589b0a6e9a46f4 (patch)
tree3e084f69b6da586f1c4fe0ea250831565c29cea5 /config/hypr/UserScripts/Weather.py
parent1788691d242abe607add69d211478e306a154cc6 (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/Weather.py')
-rwxr-xr-xconfig/hypr/UserScripts/Weather.py10
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}"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage