From 83b6ca2b129cb31aed8d27efb856f55e33a2f3eb Mon Sep 17 00:00:00 2001 From: vatsal-afk Date: Tue, 15 Oct 2024 23:20:59 +0530 Subject: [PATCH 1/3] add weather plugin --- pyproject.toml | 2 +- src/yodapa/plugins/weather.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/yodapa/plugins/weather.py diff --git a/pyproject.toml b/pyproject.toml index e9239cb..41bc9bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ homepage = "https://yoda-pa.github.io/yoda" [tool.poetry.dependencies] python = "^3.9" -typer = "^0.12.5" pyyaml = "^6.0.2" mkdocs = "^1.6.1" mkdocs-material = "^9.5.39" @@ -25,6 +24,7 @@ sqlmodel = "^0.0.22" requests = "^2.32.3" speedtest-cli = "^2.1.3" python-whois = "^0.9.4" +typer = "^0.12.5" [tool.poetry.group.docs.dependencies] diff --git a/src/yodapa/plugins/weather.py b/src/yodapa/plugins/weather.py new file mode 100644 index 0000000..8cbc10c --- /dev/null +++ b/src/yodapa/plugins/weather.py @@ -0,0 +1,14 @@ +import requests +import click +import typer + +app = typer.Typer() + +@app.command() +def get_weather(location): + location_id = location.strip().replace(" ", "+") + + weather_service = "http://wttr.in/" + + response = requests.get(weather_service + location) + click.echo(response.text) From dc5acda87cb2774d59eeb6473b1e5d98abc37cd1 Mon Sep 17 00:00:00 2001 From: Vatsal Agarwal <144194722+vatsal-afk@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:44:09 +0530 Subject: [PATCH 2/3] Update weather.py --- src/yodapa/plugins/weather.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/yodapa/plugins/weather.py b/src/yodapa/plugins/weather.py index 8cbc10c..8e048a6 100644 --- a/src/yodapa/plugins/weather.py +++ b/src/yodapa/plugins/weather.py @@ -2,7 +2,16 @@ import click import typer -app = typer.Typer() +app = typer.Typer(help=""" + weather plugin. Get the weather for a location. + + Example: + + $ yoda weather get_weather "New York" + + // New York is an example, replace with desired location + + """) @app.command() def get_weather(location): From fe046a55e4c266ffddc3a1b315f369a922576522 Mon Sep 17 00:00:00 2001 From: Vatsal Agarwal <144194722+vatsal-afk@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:02:05 +0530 Subject: [PATCH 3/3] Update src/yodapa/plugins/weather.py Co-authored-by: Man Parvesh Singh Randhawa --- src/yodapa/plugins/weather.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yodapa/plugins/weather.py b/src/yodapa/plugins/weather.py index 8e048a6..217bb04 100644 --- a/src/yodapa/plugins/weather.py +++ b/src/yodapa/plugins/weather.py @@ -13,7 +13,7 @@ """) -@app.command() +@app.command(name="get") def get_weather(location): location_id = location.strip().replace(" ", "+")