testing weather replacement funciton so it can be re-worked

This commit is contained in:
David Bures
2024-06-26 12:44:47 -07:00
parent 467f172fde
commit 3fbc294c86
2 changed files with 51 additions and 8 deletions
+13 -8
View File
@@ -101,7 +101,17 @@ def get_weather(lat=0, lon=0, unit=0):
# extract data from rows
for row in rows:
# shrink the text
line = row.text.replace("Monday", "Mon ") \
line = replace_weather(row.text)
# only grab a few days of weather
if len(weather.split("\n")) < DAYS_OF_WEATHER:
weather += line + "\n"
# trim off last newline
weather = weather[:-1]
return weather
def replace_weather(row):
line = row.replace("Monday", "Mon ") \
.replace("Tuesday", "Tue ") \
.replace("Wednesday", "Wed ") \
.replace("Thursday", "Thu ") \
@@ -130,10 +140,5 @@ def get_weather(lat=0, lon=0, unit=0):
.replace("precipitation", "precip") \
.replace("showers", "shwrs") \
.replace("thunderstorms", "t-storms")
# only grab a few days of weather
if len(weather.split("\n")) < DAYS_OF_WEATHER:
weather += line + "\n"
# trim off last newline
weather = weather[:-1]
return weather
return line