Skip to content

Commit 41a76e7

Browse files
Add Finland weather CLI
Fetches current conditions and 7-day forecasts for major Finnish cities from Open-Meteo, with Celsius/Fahrenheit output support.
1 parent c0ca7e9 commit 41a76e7

4 files changed

Lines changed: 405 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
__pycache__/
2+
*.pyc
3+
14
node_modules/
25
.env
36
npm-debug.log*

readme.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Finland Weather CLI
2+
====================
3+
4+
A terminal application that prints current weather statistics for major
5+
cities in Finland: Helsinki, Espoo, Tampere, Vantaa, Oulu, Turku,
6+
Jyvaskyla, and Lahti.
7+
8+
Weather data comes from Open-Meteo (https://open-meteo.com), a free
9+
service that requires no API key or signup. The script uses only the
10+
Python standard library, so there is nothing to install.
11+
12+
Requirements
13+
------------
14+
- Python 3.x
15+
- An internet connection (to fetch live weather data)
16+
- No pip installation needed - the script uses only the Python standard
17+
library, so there are no third-party packages to install
18+
19+
Usage
20+
-----
21+
Run from inside the weather_app folder:
22+
23+
python weather.py
24+
25+
This prints a table with current temperature, feels-like temperature,
26+
humidity, wind speed/direction, and conditions for all cities.
27+
28+
To see detailed stats for a single city, pass its name as an argument
29+
(case-insensitive):
30+
31+
python weather.py tampere
32+
python weather.py Helsinki
33+
34+
If the city name is not recognized, the script prints the list of valid
35+
city names and exits with a non-zero status.
36+
37+
To see a 7-day forecast instead of current conditions, add the -f (or
38+
--forecast) flag. It works both with a single city and with all cities:
39+
40+
python weather.py Helsinki --forecast
41+
python weather.py -f
42+
43+
Each forecast shows, per day: condition, high/low temperature, total
44+
precipitation, and max wind speed.
45+
46+
By default, temperatures are shown in Celsius. Use -u (or --units) to
47+
show Fahrenheit instead. This works with any of the modes above:
48+
49+
python weather.py -u fahrenheit
50+
python weather.py Helsinki -u fahrenheit
51+
python weather.py Helsinki -f -u fahrenheit
52+
53+
Notes
54+
-----
55+
- If a city's data cannot be fetched (e.g. no internet connection), the
56+
script prints an error for that city instead of crashing.
57+
- Non-ASCII city names (like Jyvaskyla) are displayed correctly even on
58+
Windows terminals that don't default to UTF-8.

skill.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Manual Verification Steps: weather.py
2+
3+
Run these checks after any change to `weather.py` to confirm the CLI still
4+
works end to end. All commands are run from inside `weather_app/` with an
5+
active internet connection (the app calls the live Open-Meteo API).
6+
7+
## 1. Default table (all cities, current conditions)
8+
9+
```
10+
python weather.py
11+
```
12+
13+
Expect: a table with one row per city (Helsinki, Espoo, Tampere, Vantaa,
14+
Oulu, Turku, Jyväskylä, Lahti) showing temp, feels-like, humidity, wind
15+
speed/direction, and condition. "Jyväskylä" must render correctly, not as
16+
mojibake (e.g. `Jyv?skyl?`).
17+
18+
## 2. Single city, current conditions
19+
20+
```
21+
python weather.py Tampere
22+
python weather.py tampere
23+
```
24+
25+
Expect: both commands (case-insensitive) print the same detailed block
26+
(condition, temperature, feels like, humidity, wind, precipitation,
27+
observed-at timestamp) for Tampere.
28+
29+
## 3. Unknown city
30+
31+
```
32+
python weather.py NotACity
33+
echo $?
34+
```
35+
36+
Expect: an error message listing the 8 valid city names, printed to
37+
stderr, and a non-zero exit code (1).
38+
39+
## 4. 7-day forecast
40+
41+
```
42+
python weather.py -f
43+
python weather.py Helsinki --forecast
44+
```
45+
46+
Expect: `-f` alone prints a 7-day forecast block for every city in turn
47+
(date, condition, high/low, precipitation, max wind). `Helsinki --forecast`
48+
prints just Helsinki's block. Columns should stay aligned even when the
49+
condition text is long (e.g. "Slight rain showers").
50+
51+
## 5. Units flag
52+
53+
```
54+
python weather.py -u fahrenheit
55+
python weather.py Helsinki -u fahrenheit
56+
python weather.py Helsinki -f -u fahrenheit
57+
python weather.py -u kelvin
58+
```
59+
60+
Expect: the first three print Fahrenheit values (suffixed `F`) in the
61+
table, single-city, and forecast modes respectively, with sensible values
62+
(e.g. ~50-60F for a Finnish autumn day, not obviously wrong). The last
63+
command should reject `kelvin` with an argparse usage/error message and
64+
exit code 2, since only `celsius` and `fahrenheit` are valid choices.
65+
66+
## 6. Network failure handling
67+
68+
Simulate an unreachable API by temporarily pointing the script at a bad
69+
host, e.g.:
70+
71+
```
72+
python -c "
73+
import weather
74+
weather.API_URL = 'https://nonexistent.invalid.example/v1/forecast'
75+
weather.print_table(weather.CITIES)
76+
"
77+
```
78+
79+
Expect: one error line per city (not a raw traceback), and the script
80+
does not crash.
81+
82+
## 7. Readme accuracy
83+
84+
Re-read `readme.txt` after any CLI flag change and confirm every documented
85+
command still matches the actual `argparse` options in `weather.py`
86+
(currently: optional `city` positional, `-f`/`--forecast`,
87+
`-u`/`--units {celsius,fahrenheit}`).

0 commit comments

Comments
 (0)