0 purchases
weather2 1.6.2
weather - Access weather forecast
Installation
pip install weather
Usage
import weather
forecast=weather.forecast()
forecast.today['6:00'].temp # Get temperature in current location at 6.00
Different places
If you want to get forecast from different place, pass forecast an argument.
import weather
forecast=weather.forecast('New York')
forecast.tommorow['11:00'].precip # Get precipitation in New York at 11.00
Different sources
weather supports two weather sources:
Yr.No
7timer!
If you want to get weather from different source, pass forecast argument called source.
weather.forecast(service='yrno')
weather.forecast(service='7timer')
Weather properties
wind: Instance of Wind()
Properties:
speed: Integer
Speed in m/s
direction: Instance of Direction()
Properties:
angle: Integer
Angle in degrees
direction: String
Angle in compass point ('N','NE','E','SE','S','SW',
'W', or 'NW')
temp: Float/Integer
Temperature in °C or °F (not °K) (default °C, see 'Changing units')
humid (yr.no only, other services will return None): Float/Integer
Humidity in %.
precip (7timer will return bool): Float/Integer
Precipitation amount in milimeters
Changing units
weather.forecast('New york', unit=weather.CELSIUS)#or weather.FAHRENHEIT
CLI
Just run weather:
[user@localhost ~] weather
If you want to get all avaliable switches, use weather -h:
usage: weather [-h] [--city CITY] [--country COUNTRY] [-d] [-s SERVICE]
[-u] [-a]
Python app for getting weather forecast
options:
-h, --help show this help message and exit
--city CITY City for forecast (if not passed, using current
location)
--country COUNTRY Country for forecast (see above)
-d, --debug Debug
-s SERVICE, --service SERVICE
Service to use ("yrno" or "7timer"). Implied with
"average"(try to optimise the service)
-u, --ugly Toggle JSON output
-a, --api Just print the data (implies JSON output)
That says basically enough to use it.
License
weather is licensed under MIT license
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.