From bd5373efd9356c2dcd183c6aa1709620d110d4f2 Mon Sep 17 00:00:00 2001 From: Chris Mekelburg Date: Sun, 20 Oct 2024 19:48:33 -0400 Subject: [PATCH] some help as I work thorugh weather.py Submitting for some help on the weather.py file. It is not printing the help for me nor letting me input a location with -h or -l as I mentioned on Discord. --- weather/weather.py | 20 ++++++++++++++++++-- weather/weather_cli.py | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/weather/weather.py b/weather/weather.py index 75fd2f6..727f344 100644 --- a/weather/weather.py +++ b/weather/weather.py @@ -8,7 +8,7 @@ # # It's your job to implement this function. -from weather.weather_apis import ( +from weather_apis import ( geocode_location, estimate_location, get_weather_office, @@ -21,4 +21,20 @@ def print_weather(location=None, metric=False, verbose=False): 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! + if location == None: + coordinates = estimate_location() + else: + coordinates = geocode_location(location) + + office_info = get_weather_office(coordinates["lat"], coordinates["lng"]) + office_only = office_info["office"] + + all_forecasts = get_forecast(office_info["office"], office_info["x"], office_info["y"]) + print(all_forecasts) + print() + print("The forecast for", office_only, "is") + for forecast in all_forecasts: + print(forecast["name"],"temperature of", forecast["temperature"], "wind speed of", forecast["wind_speed"], "out of the ", forecast["wind_direction"],"conditions of", forecast["description"]) # YOUR CODE HERE! + print() + +print_weather() \ No newline at end of file diff --git a/weather/weather_cli.py b/weather/weather_cli.py index 9b27f69..a8e125b 100644 --- a/weather/weather_cli.py +++ b/weather/weather_cli.py @@ -9,7 +9,7 @@ # You don't need to do anything with thie file. from argparse import ArgumentParser -from weather.weather import print_weather +from weather import print_weather def weather_cli(): """Provides a command-line interface for weather.