updating latest from mac

This commit is contained in:
2019-11-25 18:13:52 +00:00
parent 3e8988f369
commit 1c76e1801c
73 changed files with 2267 additions and 202 deletions

View File

@@ -0,0 +1,13 @@
from .__version__ import __version__ # noqa
import requests
def current_weather(location, api_key):
url = 'https://api.openweathermap.org/data/2.5/weather'
query_params = {
'q': location,
'appid': api_key,
}
response = requests.get(url, params=query_params)
return response.json()['weather'][0]['description']

View File

@@ -0,0 +1 @@
__version__ = '0.1.0'

View File

@@ -0,0 +1,27 @@
import weather_cli
import click
@click.group()
@click.version_option(version=weather_cli.__version__)
def main(version):
pass
@main.command()
@click.argument('location')
@click.option(
'--api-key', '-a', help='your API key for the OpenWeatherMap API'
)
def current(location: str, api_key: str):
"""Query the openWeather API for the current weather conditions
"""
# import pudb; pudb.set_trace()
if api_key is None:
api_key = weather_cli.SAMPLE_API_KEY
weather = weather_cli.current_weather(location=location, api_key=api_key)
print(f'The weather in {location} is {weather}')
if __name__ == "__main__":
main()