v.0.6.1 URLEncoder.encode_utf8
This commit is contained in:
@@ -13,9 +13,8 @@ ACTUAL_WEATHER_URL = 'http://api.weatherapi.com/v1/current.json?key={API_KEY}&q=
|
||||
|
||||
class Weather_Checker():
|
||||
|
||||
def __init__(self, city: str, display: NeoPixel_64x64):
|
||||
def __init__(self, display: NeoPixel_64x64):
|
||||
self.display = display
|
||||
self.city = URLEncoder.encode(city) # url_encode
|
||||
self.display.set_font( font=fonts.font_5x7)
|
||||
|
||||
def mock_weather_data(self):
|
||||
@@ -34,7 +33,7 @@ class Weather_Checker():
|
||||
return None
|
||||
|
||||
|
||||
def actual_weather(self, city='grosshansdorf', lang='de', test_mode=False) -> Weather:
|
||||
def actual_weather(self, city, lang, test_mode=False) -> Weather:
|
||||
weather_url = ACTUAL_WEATHER_URL.format(API_KEY=API_KEY, city=city, lang=lang)
|
||||
|
||||
if not test_mode:
|
||||
@@ -59,11 +58,12 @@ class Weather_Checker():
|
||||
return weather
|
||||
|
||||
|
||||
def check(self, test_mode: bool = False):
|
||||
def check(self, city:str, lang:str, test_mode: bool = False):
|
||||
try:
|
||||
self.display.clear()
|
||||
|
||||
w_resp: Weather = self.actual_weather(city=self.city, lang='de', test_mode=test_mode)
|
||||
city = URLEncoder.encode_utf8(city) # url_encode
|
||||
w_resp: Weather = self.actual_weather(city=city, lang=lang, test_mode=test_mode)
|
||||
|
||||
ypos = 0
|
||||
self.display.write_text(f'{str(w_resp.location.name)}', 0, ypos, color=colors.RAINBOW[0])
|
||||
|
||||
Reference in New Issue
Block a user