Skip to content

murilobsd/weather-mini-challenge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis (.org) branch Codecov Read the Docs

Weather Mini Challenge

Suppose you live in Ribeirão Preto. Should you take an umbrella?

You tell us!

If the air humidity on a given day is greater than 70%, it is a good idea to take an umbrella with you. Your goal is to fetch the Ribeirão Preto air humidity forecast for the next five days from https://openweathermap.org/api and display the following message template:

You should take an umbrella in these days: ....

For instance, if on the next five days air humidity will be greater than 70% on Monday, Tuesday and Wednesday, you must display the message:

You should take an umbrella in these days: Monday, Tuesday and Wednesday.

Requirements

Setup

$ pip install --user .

Run

There are two ways for you to enjoy the umbrella challenge:

Running the simple script

In that case you can use the -h option to return help on how to use the script.

$ iclinic_wea.py --help
usage: iclinic_wea.py [-h] [-l LIMIT] [-t TIMEOUT] [-v] api_key city

IClinic Weather Challenge.

positional arguments:
  api_key               api key: https://home.openweathermap.org/api_keys
  city                  city name eg: "Ribeirão Preto"

optional arguments:
  -h, --help            show this help message and exit
  -l LIMIT, --limit LIMIT
                        limit humidity eg: 70
  -t TIMEOUT, --timeout TIMEOUT
                        connection timeout default: 10
  -v, --verbose         increases log verbosity for each occurence.

The example below checks if I will need the umbrella for the next five days in the city of ribeirão preto.

$ export APIKEY=.....
$ iclinic_wea.py --limit 70 "$APIKEY" "Ribeirão Preto"

Note the limit argument has a default value of 70, but it can be changed.

$ export APIKEY=.....
$ iclinic_wea.py --limit 41.1 "$APIKEY" "Ribeirão Preto"
You should take an umbrella in these days: Monday, Tuesday, Wednesday, Thursday and Friday.

If you want to view in a more verbose way, increase -v.

$ export APIKEY=.....
$ iclinic_wea.py --limit 41.1 "$APIKEY" "Ribeirão Preto" -v
iclinic-weather (INFO): Forecast: [Ribeirão Preto]
iclinic-weather (INFO): you won't need an umbrella

Importing the module

from iclinic_wea import umbrella

_args = {'city': 'Ribeirão Preto', 'appid': 'API KEY', 'limit': 70, 'timeout': 10}
umbrella(_args)
You should take an umbrella in these days: Tuesday and Wednesday.

Docs

Required Sphinx

$ cd docs/
$ make html
$ python3 -m http.server --directory __build/html
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/)

Tests

$ make test

About

Weather Mini Challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.8%
  • Makefile 2.2%