]> ToastFreeware Gitweb - chrisu/seepark.git/commitdiff
PEP8 coding style changes.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 23 Sep 2025 17:46:21 +0000 (19:46 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 23 Sep 2025 17:46:21 +0000 (19:46 +0200)
owm.py

diff --git a/owm.py b/owm.py
index bd6ba6efb325be3c2cdedb983849a31422b8bf84..237c3d771e20fee2098ec64cb68a077ed7439d82 100755 (executable)
--- a/owm.py
+++ b/owm.py
@@ -28,7 +28,7 @@ def fromtimestamp(timestamp):
 
 
 # https://stackoverflow.com/questions/7490660/converting-wind-direction-in-angles-to-text-words
 
 
 # https://stackoverflow.com/questions/7490660/converting-wind-direction-in-angles-to-text-words
-def degToCompass(num):
+def deg_to_compass(num):
     if num is None or num is math.nan:
         return 'N/A'
     val=int((num/22.5)+.5)
     if num is None or num is math.nan:
         return 'N/A'
     val=int((num/22.5)+.5)
@@ -36,7 +36,7 @@ def degToCompass(num):
     return arr[(val % 16)]
 
 
     return arr[(val % 16)]
 
 
-def extractweatherdata(w):
+def extract_weather_data(w):
     data = dict(
         datetime = fromtimestamp(w['dt']),
         sunrise = fromtimestamp(w['sys']['sunrise']),
     data = dict(
         datetime = fromtimestamp(w['dt']),
         sunrise = fromtimestamp(w['sys']['sunrise']),
@@ -51,7 +51,7 @@ def extractweatherdata(w):
     )
 
     data['winddegrees'] = w['wind']['deg'] if 'deg' in w['wind'] else math.nan
     )
 
     data['winddegrees'] = w['wind']['deg'] if 'deg' in w['wind'] else math.nan
-    data['winddirection'] = degToCompass(data['winddegrees'])
+    data['winddirection'] = deg_to_compass(data['winddegrees'])
     data['precipitation'] = w['rain']['3h'] if 'rain' in w and w['rain'].get('3h') else math.nan
     data['visibility'] = w.get('visibility', math.nan)
 
     data['precipitation'] = w['rain']['3h'] if 'rain' in w and w['rain'].get('3h') else math.nan
     data['visibility'] = w.get('visibility', math.nan)
 
@@ -106,7 +106,7 @@ def main(configfile, debug):
     url, weather_json = openweathermap_json(apikey, cityid)
     if debug:
         pprint(weather_json)
     url, weather_json = openweathermap_json(apikey, cityid)
     if debug:
         pprint(weather_json)
-    weather_data = extractweatherdata(weather_json)
+    weather_data = extract_weather_data(weather_json)
     if debug:
         pprint(weather_data)
 
     if debug:
         pprint(weather_data)