From 73437acb67281cd002ddf8408953b56e43ace3d8 Mon Sep 17 00:00:00 2001 From: NCLanceman Date: Thu, 19 Jun 2025 15:51:16 -0500 Subject: [PATCH] head banging --- __pycache__/iconSelector.cpython-311.pyc | Bin 0 -> 2888 bytes iconSelector.py | 36 ++++++++++++++++++----- weather.py | 11 +++---- 3 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 __pycache__/iconSelector.cpython-311.pyc diff --git a/__pycache__/iconSelector.cpython-311.pyc b/__pycache__/iconSelector.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a00097b88b091fce9954fa573f08044b1f9d0ffc GIT binary patch literal 2888 zcmb_eTW=Fb6rS;AEPj^%G>FjO%xPYpM&s#iXxv8x5v-yDPUC_n?ZM3VsNS^KgJkcbuQ}); zG#)h_l=c&ETF4>d`x&Quh@S{KPdY$)NC3V;z=ME?;2VN(n1o3L@CXr!1YeOvZ=mMgpO-Vs;AK@gLtVd7)U;LC zM>C4%_8576MW#m5>w0hKIoDTE3>aV(^qVqZz7<6yuAf;LpDP-s;R;z*FM=D;Vft(a z=%Se~Y6MhFofZr?((Yz)YXcGTLYuu$1wikkGTLbC+-^RG0e{r$Tf=2M ziLTA9dCDHM6+wiS5yf{RfC;Uk4D&+FAqs#8x^OSYc`nua8hjteBVBwy$E7Y@;CQSH z@0msQ*+~HMAUN|3CukU0RAeT~OfNJ2%nX8Yfd#Q-fr8L1sfy`_GGtNCn#!_lxFH_b zd7To&4YH`#n*oSt17z{5H-QVmYqWX1c$_+XmNqofr5axNr=Hl0yM?1U& zHK9|@###v0-P2g<=dW$ufzFwBwC-S++V8OHP-E3cFxtVMguArA2JOge(H6V3XNmM0 zvLf20I~v@{9>hBJ%KTKCp+k^$ydJq;l38^_Mj@lBm*7Wkl;XV7i~&5x(eWiMSL&~W z8aryXVP3sT1I;s{W6WR+?;OS|UrAyGt4)g)!P0R1v0{v|Lf1xNwX-BW50-kfI+4fV zWZWhueXd70T;CEqbbX6DoPn`yky2SRCl$(z*lN;C-vl`~XetHylN*z;3j&pmqG~pa zB0a+TMWv9*$<5kFPXKldUSkb@?-k^TQ7C62$r1ak`Sp1VZYMhU;Dg7}k!o~gbI;I^ zyMG$~VR*Ce(1uz)ap{Q{@4bxwMaNAXz;*=CnYM`D1^|&>+K4-zb*}wbl{QaxnU)_u)HjY)_dJp&m z7a1R{H3fX}BJhW-g>@*&)G5t>VOVp)K-Xv3<;;Wcqssf7i zR;KAu2tzXF_OK|c%9oTCQ_B7;pyOa%At#&J6++);PGmd$AHGlbG17i!63mP+bAXwH z%p78d9cMh)zal;nPljiKcMCcxs`7by7W!GmH+}Dt`c# k1|Ec};z2g%jR#*<#qmn0CJbV!hFa!S0{7NXx8Z-z|1a^K;s5{u literal 0 HcmV?d00001 diff --git a/iconSelector.py b/iconSelector.py index b9e4b87..d970f94 100644 --- a/iconSelector.py +++ b/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 diff --git a/weather.py b/weather.py index 71dbc71..33686c1 100644 --- a/weather.py +++ b/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" \u2601 {condition}, {roundedTemp} F") print( - f"{weatherIconImage} {roundedTemp}F") + f"{weatherIcon}{roundedTemp}F") print(tooltipPrinter(request_json))