mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-08-09 18:33:03 +02:00
testing weather replacement funciton so it can be re-worked
This commit is contained in:
+13
-8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user