summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE2
-rwxr-xr-xnwscap.py12
2 files changed, 9 insertions, 5 deletions
diff --git a/LICENSE b/LICENSE
index 0fbf805..4fd0b86 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright 2013-2014 Daniel Washburn
+Copyright 2013-2017 Daniel Washburn
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
diff --git a/nwscap.py b/nwscap.py
index 939a5eb..20c0d46 100755
--- a/nwscap.py
+++ b/nwscap.py
@@ -2,12 +2,13 @@
"""Parse active NOAA NWS CAP advisories and output an ATOM feed"""
__author__ = 'Daniel Washburn'
-__copyright__ = 'Copyright (c) 2013, 2014, All rights reserved.'
+__copyright__ = 'Copyright (c) 2013-2017'
__license__ = 'http://opensource.org/licenses/BSD-3-Clause'
import cgi
import getopt
import sys
+import urllib2
from lxml import etree
from lxml.etree import SubElement
@@ -18,7 +19,8 @@ CAP_NAMESPACE = {'cap': CAP_URI}
CAP_SCHEMA_URL = 'http://docs.oasis-open.org/emergency/cap/v1.1/errata/approved/cap.xsd'
CAP_XSLT_URL = 'capatomcustom.xsl'
-CAP_SCHEMA = etree.XMLSchema(etree.parse(CAP_SCHEMA_URL))
+cap_schema_url = urllib2.urlopen(CAP_SCHEMA_URL)
+CAP_SCHEMA = etree.XMLSchema(etree.parse(cap_schema_url))
CAP_XSLT = xslt_transform = etree.XSLT(etree.parse(CAP_XSLT_URL))
ATOM_PARSER = etree.XMLParser(ns_clean=True, remove_comments=True)
@@ -71,7 +73,8 @@ else:
usage()
sys.exit()
-in_feed = etree.parse(url, ATOM_PARSER)
+feed=urllib2.urlopen(url)
+in_feed = etree.parse(feed, ATOM_PARSER)
out_feed = etree.XML('''<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<feed xmlns='http://www.w3.org/2005/Atom'/>''')
@@ -103,7 +106,8 @@ if no_alerts_title in entry_titles[0].text:
alert_links = []
for link in alert_links:
- cap=etree.parse(link, CAP_PARSER)
+ cap_link=urllib2.urlopen(link)
+ cap=etree.parse(cap_link, CAP_PARSER)
cap_entry = SubElement(out_feed, 'entry')
SubElement(cap_entry, 'id').text = "%s" % \
cap.xpath('/cap:alert/cap:identifier',