Browse files


  • Loading branch information...
1 parent 707a934 commit 2fba7ed69acceefa384f18d8f29a5e46f6cb92f6 @zebpalmer committed Mar 11, 2013
Showing with 17 additions and 10 deletions.
  1. +5 −1 weatheralerts/
  2. +1 −1 weatheralerts/
  3. +11 −8 weatheralerts/
@@ -46,12 +46,16 @@ def raw_cap(self, refresh=False):
def refresh(self):
- Refresh the feed bypassing the cache
+ NOTE: You probably don't want to call this... This does not update the alerts loaded
+ in the WeatherAlerts object, only the underlying feed. This is only used internally now and as such,
+ will likely be deprecated soon. Please call WeatherAlerts.refresh() instead.
raw = self._get_nws_feed()
return raw
def _get_nws_feed(self):
'''get nws alert feed, and cache it'''
url = '''''' % (self._state)
@@ -8,7 +8,7 @@ def setUp(self):
self.nws = WeatherAlerts()
def test_almost_everything(self):
- print "Alerts currently in feed {0}".format(self.nws.alert_count)
+ print "Alerts currently in feed {0}".format(len(self.nws.alerts)
def test_event_state_counties(self):
@@ -12,8 +12,11 @@ class WeatherAlerts(object):
def __init__(self, state=None, samecodes=None, load=True, cachetime=3):
- init Alerts, default to National Feed, set state level samecodes or county codes the area in which you want to
- load alerts.
+ WeatherAlerts Init
+ *Defaults to National Feed, it can be quite large at times, you probably don't want to parse it very often.
+ *Set a state to see all alerts on your state feed.
+ *For local alerts only, set samecodes to a single samecode string, or list of samecode strings. This will
+ pull your state feed automatically.
self._alerts = None
self._feed = None
@@ -59,6 +62,10 @@ def refresh(self, force=False):
def alerts(self):
+ '''returns the alerts list. If samecode(s) are specified when the WeatherAlerts object is created,
+ this will only return alerts for those samecodes. If no samecodes were given, it'll return all alerts for the
+ state if one was specified otherwise for the entire U.S.
+ '''
if self.samecodes is not None:
temp = []
for alert in self._alerts:
@@ -69,13 +76,9 @@ def alerts(self):
return self._alerts
- @property
- def alert_count(self):
- '''simple property for checking the number of alerts, mainly for debugging purposes'''
- return len(self._alerts)
def samecode_alerts(self, samecode):
- '''Returns alerts for specified SAME geocodes'''
+ '''Returns alerts for a ()single) SAME geocode. Only useful if you didn't specify samecodes when the WeatherAlerts
+ object was created.'''
return [x for x in self._alerts if samecode in x.samecodes]
def county_state_alerts(self, county, state):

0 comments on commit 2fba7ed

Please sign in to comment.