Browse Source

head banging

master
NCLanceman 5 months ago
parent
commit
73437acb67
  1. BIN
      __pycache__/iconSelector.cpython-311.pyc
  2. 36
      iconSelector.py
  3. 11
      weather.py

BIN
__pycache__/iconSelector.cpython-311.pyc

Binary file not shown.

36
iconSelector.py

@ -1,3 +1,10 @@
from pathlib import Path, PurePosixPath
import os
currentDirectory = os.getcwd()
currentDirHC = "/home/nclanceman/tools/weather"
# currentDirectory = PurePosixPath(Path.cwd())
adjectives = ["severe", "scattered", "partly", "mostly", "light", "heavy"]
clearWords = ["clear", "sunny"]
rainWords = ["rain", "showers"]
@ -35,22 +42,35 @@ def parseDescription(desc):
def imageSelector(desc, timeOfDay):
result = ""
match desc:
case "clear":
if timeOfDay == "day":
return "/smallIcons/clear-day-small.png"
result = os.path.join(
currentDirectory, 'smallIcons', 'clear-day-small.png')
else:
return "/smallIcons/clear-night-small.png"
result = os.path.join(
currentDirectory, 'smallIcons', 'clear-night-small.png')
case "cloudy":
if timeOfDay == "day":
return "/smallIcons/overcast-day-small.png"
result = os.path.join(
currentDirectory, 'smallIcons', 'overcast-day-small.png')
else:
return "/smallIcons/overcast-night-small.png"
result = os.path.join(
currentDirectory, 'smallIcons', 'overcast-night-small.png')
case "wind":
return "/smallIcons/wind-small.png"
result = os.path.join(
currentDirectory, 'smallIcons', 'wind-small.png')
case "thunderstorm":
return "/smallIcons/thunderstorms-rain-small.png"
result = os.path.join(
currentDirectory, 'smallIcons', 'thunderstorms-rain-small.png')
case "rain":
return "/smallIcons/rain-small.png"
result = os.path.join(
currentDirectory, 'smallIcons', 'rain-small.png')
case _:
result = os.path.join(
currentDirectory, 'smallIcons', 'code-red-small.png')
return "/smallIcons/code-red-small.png"
return result

11
weather.py

@ -2,10 +2,8 @@ import requests
import math
import sys
import iconSelector as iconSelect
import os
currentDirectory = os.getcwd()
CDHardcode = "/home/nclanceman/tools/weather"
weatherIcon = ""
try:
stationName = sys.argv[1]
@ -98,11 +96,10 @@ else:
temp = convertToF(request_json["properties"]["temperature"]["value"])
roundedTemp = rounding(temp)
condition = request_json["properties"]["textDescription"]
parsedCondition = iconSelect.parseDescription(condition)
timeOfDay = request_json['properties']['icon'].split("/")[5]
weatherIcon = iconSelect.parseDescription(condition)
weatherIconImage = currentDirectory +\
iconSelect.imageSelector(weatherIcon, timeOfDay)
weatherIcon = iconSelect.imageSelector(parsedCondition, timeOfDay)
# print(f"<txt> \u2601 {condition}, {roundedTemp} F</txt>")
print(
f"<img>{weatherIconImage}</img><txt> {roundedTemp}F</txt>")
f"<img>{weatherIcon}</img><txt>{roundedTemp}F</txt>")
print(tooltipPrinter(request_json))

Loading…
Cancel
Save