[WIP] Add weather icons
This commit is contained in:
		
							
								
								
									
										39
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								main.py
									
									
									
									
									
								
							| @@ -64,12 +64,21 @@ def display_full(data): | |||||||
|  |  | ||||||
|         wind_speed = infos["data"]["instant"]["details"]["wind_speed"] |         wind_speed = infos["data"]["instant"]["details"]["wind_speed"] | ||||||
|  |  | ||||||
|         wind_direction = display_wind_direction( |         wind_dir = display_wind_direction( | ||||||
|             infos["data"]["instant"]["details"]["wind_from_direction"] |             infos["data"]["instant"]["details"]["wind_from_direction"] | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         cur_humidity = infos["data"]["instant"]["details"]["relative_humidity"] |         icon_str = '' | ||||||
|         print(f"  {time} : {temperature}° / {cur_humidity}% / {wind_direction} {wind_speed} m/s") |         if "next_12_hours" in infos["data"]: | ||||||
|  |             icon_str = infos["data"]["next_12_hours"]["summary"]["symbol_code"] | ||||||
|  |         if "next_6_hours" in infos["data"]: | ||||||
|  |             icon_str = infos["data"]["next_6_hours"]["summary"]["symbol_code"] | ||||||
|  |         if "next_1_hours" in infos["data"]: | ||||||
|  |             icon_str = infos["data"]["next_1_hours"]["summary"]["symbol_code"] | ||||||
|  |         icon = display_icon(icon_str) | ||||||
|  |  | ||||||
|  |         humidity = infos["data"]["instant"]["details"]["relative_humidity"] | ||||||
|  |         print(f"  {time} : {icon}  {temperature}° / {humidity}% / {wind_dir} {wind_speed} m/s") | ||||||
|  |  | ||||||
|  |  | ||||||
| def display_wind_direction(degrees: float) -> str: | def display_wind_direction(degrees: float) -> str: | ||||||
| @@ -98,6 +107,30 @@ def display_wind_direction(degrees: float) -> str: | |||||||
|     return '↓' |     return '↓' | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def display_icon(string: str) -> str: | ||||||
|  |     """ """ | ||||||
|  |     # https://www.nerdfonts.com/cheat-sheet | ||||||
|  |     t = { | ||||||
|  |         'clearsky_day': fg.yellow + '' + fg.rs, | ||||||
|  |         'clearsky_night': '', | ||||||
|  |         'cloudy': '', | ||||||
|  |         'fog': '', | ||||||
|  |         'lightrain': '', | ||||||
|  |         'heavyrain': '', | ||||||
|  |         'partlycloudy_night': '', | ||||||
|  |         'partlycloudy_day': '', | ||||||
|  |         'rain': '', | ||||||
|  |         'lightrainshowers_night': '', | ||||||
|  |         'lightrainshowers_day':'', | ||||||
|  |         'fair_day': fg.yellow + '' + fg.rs, | ||||||
|  |         'fair_night': '', | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if string in t: | ||||||
|  |         return t[string] | ||||||
|  |  | ||||||
|  |     return string | ||||||
|  |  | ||||||
| def coloring_temperature(temperature: float) -> str: | def coloring_temperature(temperature: float) -> str: | ||||||
|     """ A partir de la température retourne une chaine de caractères colorisée """ |     """ A partir de la température retourne une chaine de caractères colorisée """ | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user