diff options
| author | prabinpanta0 <pantaprabin30@gmail.com> | 2025-10-27 11:52:04 +0545 |
|---|---|---|
| committer | prabinpanta0 <pantaprabin30@gmail.com> | 2025-10-27 11:52:04 +0545 |
| commit | 94e1d96814cdaf41da1f4129f6a01447bd771af6 (patch) | |
| tree | 580fb9171a705f550f5de0a9a79a8dd96690545e /config/hypr/UserScripts | |
| parent | a8b355b490d6f0d4e5e5e219426ddffd26ca19f1 (diff) | |
config(hypr): preserve fetched/cached place and stop preemptive MANUAL/ENV override
Use the exact place value returned from fetch_place or stored in the API cache when writing/reading and when building output. Remove the early coalescing with MANUAL_PLACE/ENV_PLACE so cached/fetched place strings (including empty/None) are preserved and final selection is handled centrally by build_place_str.
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/Weather.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index ee861ebb..c7638599 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -776,9 +776,8 @@ def try_cached_weather(lat: float, lon: float) -> Optional[Tuple[Dict[str, str], aqi = cast(Optional[Dict[str, Any]], cached.get("aqi")) place_val = cached.get("place") cached_place = place_val if isinstance(place_val, str) else None - place_effective = MANUAL_PLACE or ENV_PLACE or cached_place try: - return build_output(Location(lat, lon, place_effective), forecast, aqi) + return build_output(Location(lat, lon, cached_place), forecast, aqi) except Exception as e: print(f"Cached data build failed, refetching: {e}", file=sys.stderr) return None @@ -788,9 +787,9 @@ def fetch_fresh_weather(lat: float, lon: float) -> Optional[Tuple[Dict[str, str] try: forecast = fetch_open_meteo(lat, lon) aqi = fetch_aqi(lat, lon) - place_effective = MANUAL_PLACE or ENV_PLACE or fetch_place(lat, lon) - write_api_cache({"forecast": forecast, "aqi": aqi, "place": place_effective}) - return build_output(Location(lat, lon, place_effective), forecast, aqi) + place = fetch_place(lat, lon) + write_api_cache({"forecast": forecast, "aqi": aqi, "place": place}) + return build_output(Location(lat, lon, place), forecast, aqi) except Exception as e: print(f"Open-Meteo fetch failed: {e}", file=sys.stderr) return None @@ -804,10 +803,9 @@ def try_stale_weather(lat: float, lon: float) -> Optional[Tuple[Dict[str, str], stale_dict = ensure_dict(stale) place_val = stale_dict.get("place") place = place_val if isinstance(place_val, str) else None - place_effective = MANUAL_PLACE or ENV_PLACE or place forecast = cast(Optional[Dict[str, Any]], stale_dict.get("forecast")) aqi = cast(Optional[Dict[str, Any]], stale_dict.get("aqi")) - return build_output(Location(lat, lon, place_effective), forecast, aqi) + return build_output(Location(lat, lon, place), forecast, aqi) except Exception as e2: print(f"Failed to use stale cache: {e2}", file=sys.stderr) return None |
