#@TecOEd
#Weather Parser reader from Yahoo

#!/usr/bin/env python

#http://developer.yahoo.com/weather/developers api overview

import time
import feedparser
import os

while True:
#pulls all the data down
    rss_link ='http://weather.yahooapis.com/forecastrss?w=44418&u=c' #add your area code
    d = feedparser.parse(rss_link)


    #Parse data in various elements
    location = d.feed.yweather_location #returns the location data from yahoo
    city =location['city'] # looks for the city from the location data

    atmosphere = d.feed.yweather_atmosphere # returns the atmosphere data from yahoo 
    humidity = atmosphere['humidity']

    astronomy = d.feed.yweather_astronomy #returns astronomy data from yahoo
    sunrise = astronomy['sunrise'] #returns the sunrise time
    sunset = astronomy['sunset'] #returns the sunset time

    wind = d.feed.yweather_wind
    chill = wind['chill']

    #summary
    summary = d.entries[0].summary # returns the full weather summary for area code
    #but requires spliting 
    #print summary

    #prints weather elements
    print""
    time.sleep(1)
    print "Weather for "+city
    print " "
    time.sleep(3)
    print "Sunrise for "+city, sunrise
    print ""
    time.sleep(3)
    print "Sunset for "+city, sunset
    print""
    time.sleep(3)
    print "Humidity for "+city, humidity
    print""
    time.sleep(3)
    print "Wind chill for "+city, chill, "degrees"
    time.sleep(3)
    print""

    print "Weather provided by TeCoEd"

    #print d    
