wunderapi package

Submodules

wunderapi.cli module

This module provides a CLI for the weatherapi module.

wunderapi.cli.print_conditions(api)

Prints multiline condition message.

wunderapi.cli.print_extended_forecast(api)

Prints extend forecast in a table.

wunderapi.cli.print_forecast(api)

Prints forecast in a table.

wunderapi.cli.print_table(data)

Prints table to terminal.

wunderapi.cli.print_temp(api)

Prints formatted temperate string.

wunderapi.config module

Provides the configuration for the weather module.

class wunderapi.config.Config(config_file=None)

Bases: object

Reads the default configuration from config file. If file doesn’t exist then it is created.

Parameters:config_file – Location of config file
create_config()

Creates the config file.

create_dir()

Creates defaults directory if it doesn’t exist.

parse_config(profile='default')

Reads the config file and imports settings.

wunderapi.weather module

This module is a wrapper for the Weather Underground API.

A Weather Underground developer API is required to use.

class wunderapi.weather.Weather(config_file=None, location=None, units=None, date=None)

Bases: object

Weather Underground API wrapper. Settings are read in from the config file. Any parameters passed override the config file.

Parameters:
  • config_file – Path to config file.
  • location – Zipcode of weatherstation.
  • units – Units for results {english, metric}
  • date – Format for date results. {date, day, shortday}
format_date(data)

Formats the date string.

Parameters:data – A list containing result data
Returns:String containing the formatted date based on the config.date_format.

Example

  • date - November 12
  • day - Thursday
  • shortday - Friday
format_temp(temp)

Formats the temperature string.

Parameters:temp – Temperature to be formatted
Returns:Formatted string with degree symbol and units.

Example

  • 32°F
format_wind(data)

Formats the wind string

Parameters:data – A list containing result data
Returns:String containing a formated wind string based on the config.units.

Example

  • english - 10 MPH
  • metric - 10 KPH
get_conditions(result=None)
Returns:A multiline string summary of the current conditions.
get_forecast(result=None, detail='simple')

Gets the forcast array.

Parameters:
  • result – A dictionary containing the results from the API.
  • detail – Which forecast view to obtain. ‘Simple’ returns a 4 day forecast. ‘Extended’ returns a 10 day forecast.
Returns:

An array of the forecast with the first element containing the table headings.

get_result(view)

Gets the result of the API call.

Parameters:view – The view that is being requested
Returns:A dictionary containing the decoded json result.
get_temp(result=None)
Returns:The current observation temperature.
get_url(view)

Formats the url required to retrieve the specific view.

Parameters:view – The view that is being requested.
Returns:A url for the api request.
get_wind_string(result=None)
Returns:A string containing the current wind conditions

Example

From the west at 5 KPH Gusting to 15 KPH

Module contents