diff options
| author | prabinpanta0 <pantaprabin30@gmail.com> | 2025-10-27 11:16:58 +0545 |
|---|---|---|
| committer | prabinpanta0 <pantaprabin30@gmail.com> | 2025-10-27 11:16:58 +0545 |
| commit | c47eadb340dcdea51587537f4237f347653cb675 (patch) | |
| tree | dbb9a7dda2235fb97fb8f4ba6c73eb8c75f01e07 /config/hypr/UserScripts/Weather.py | |
| parent | f930ca046894ab12bb5907ffc9b4e5cbd3a5a2e4 (diff) | |
config(hypr): preserve empty place strings & prefer MANUAL/ENV place; use explicit None checks
- Use explicit "is not None" checks when building place parts so empty strings are kept
instead of being treated as falsy.
- Build place string from MANUAL_PLACE or ENV_PLACE before reverse-geocoded place,
preserving explicit overrides and empty place values.
Diffstat (limited to 'config/hypr/UserScripts/Weather.py')
| -rwxr-xr-x | config/hypr/UserScripts/Weather.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index 7e350c30..2a3e0ad2 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -416,11 +416,11 @@ def extract_place_parts_nominatim(data_dict: JSONDict) -> List[str]: admin1 = cast(Optional[str], address.get("state")) country = cast(Optional[str], address.get("country")) parts: List[str] = [] - if name: + if name is not None: parts.append(name) - if admin1: + if admin1 is not None: parts.append(admin1) - if country: + if country is not None: parts.append(country) return parts @@ -430,11 +430,11 @@ def extract_place_parts_open_meteo(p: JSONDict) -> List[str]: admin1 = cast(Optional[str], p.get("admin1")) country = cast(Optional[str], p.get("country")) parts: List[str] = [] - if name: + if name is not None: parts.append(name) - if admin1: + if admin1 is not None: parts.append(admin1) - if country: + if country is not None: parts.append(country) return parts @@ -644,8 +644,9 @@ def build_aqi_info(aqi: Optional[Dict[str, Any]]) -> str: def build_place_str(lat: float, lon: float, place: Optional[str]) -> str: - if place: - return f"{place} ({lat:.3f}, {lon:.3f})" + effective_place = MANUAL_PLACE or ENV_PLACE or place + if effective_place: + return f"{effective_place} ({lat:.3f}, {lon:.3f})" return f"{lat:.3f}, {lon:.3f}" |
