From e5c2914a4aedbbaaf42e3193f7c46129eb84de49 Mon Sep 17 00:00:00 2001 From: grace-xing6 Date: Wed, 23 Oct 2024 11:46:49 -0400 Subject: [PATCH] weather py just save it for now --- .DS_Store | Bin 0 -> 6148 bytes weather/weather.py | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..edef7b2e0a4e5de138220214ce524df580653531 GIT binary patch literal 6148 zcmeHKL2uJA6n^dsO{qYY7*a1tk+@c+bn9W_Qpz}Rr3emyLegeySQb}Fs%TV|dWQeN zU*O6w;lFT#@7bOp=|Ex!geE`f`E%^|J=dRQyCxzrUd|p6wTZ}qGuCgQxWKrdeamX5 zr3n-&$CP}U(wsu_wxVr=Rlq9nzbU|bw}sv6(SpvfcYp3*?`bTjK`aAA@bT~n-utc$ zHKN;eL@7ns>j}-kKcXdSQ_9gMQOl^uIV)K{SF-HVF~x`vFmep$dv$gcD1Bt&lO#o+ zjOOJ$;%+5R6Jv$Qvp|;cqLIbN3ZsQsiP#(?oPoi=VoE2KalTbpw|GwQ6w&X%=K1#E zl1?cub8E*HZU=E8=8`M5{$4v?flt4zK!Zv;l}9I5`VY}TkuA*XehC(Fl;!>YS5e!k zU%TFL8cxf3Gnva`lKc5G8~f=i{(3HD9Gutv;6)S`UVHbkOmaU;!c-BWS%{F=FQa58 zi?LiLvrKU(y2EKYO|RWqt@ifzyY67PzwWxLgF(OR4hO^ay6N1xcmLrt?<77=H9$=t15ljFPAg};Tfaok3uqM$I>v8wP@ d+<_}YpUV~C$lyjJT445%fRe!$R)K%2zz=y0!}|aL literal 0 HcmV?d00001 diff --git a/weather/weather.py b/weather/weather.py index 75fd2f6..d65aa39 100644 --- a/weather/weather.py +++ b/weather/weather.py @@ -12,13 +12,51 @@ from weather.weather_apis import ( geocode_location, estimate_location, get_weather_office, - get_forecast + get_forecast, ) + def print_weather(location=None, metric=False, verbose=False): """Prints out a weather report using the provided location, or using the user's current location if no location was provided. When metric is True, prints out the weather in metric units. When verbose is True, prints out a more detailed report. """ - print("Not finished...") # YOUR CODE HERE! + try: + if not location: + location = estimate_location() + print(f"Estimated location: {location}") + + if location: + loc_data = geocode_location(location) + if loc_data: + lat, lng = loc_data['lat'], loc_data['lng'] + weather_office = get_weather_office(lat, lng) + if weather_office: + forecast = get_forecast(weather_office, lat, lng) + print(forecast) + + if forecast: + # print_forecast(forecast, metric, verbose) + forecast=get_forecast(forecast, metric, verbose) + print(forecast) + else: + print("No forecast available for the location.") + else: + print("Weather office not found for the given location.") + else: + print("Location not found.") + else: + print("No location provided, and estimated location failed.") + except Exception as e: + print(f"An error occurred: {e}") + + + # if location == None: + # if metric == False: + # return get_weather_office(estimate_location(ip_address=None)) + + # print("Not finished...") # YOUR CODE HERE! +# weather_cli( +# get_forecast( +# get_weather_office(