tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajbor...@apache.org
Subject svn commit: r507522 - /incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.alerter/RSSCheckerImpl.py
Date Wed, 14 Feb 2007 13:15:35 GMT
Author: ajborley
Date: Wed Feb 14 05:15:34 2007
New Revision: 507522

URL: http://svn.apache.org/viewvc?view=rev&rev=507522
Log:
Minor improvements to Alert Aggregator sample for stability

Modified:
    incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.alerter/RSSCheckerImpl.py

Modified: incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.alerter/RSSCheckerImpl.py
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.alerter/RSSCheckerImpl.py?view=diff&rev=507522&r1=507521&r2=507522
==============================================================================
--- incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.alerter/RSSCheckerImpl.py (original)
+++ incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.alerter/RSSCheckerImpl.py Wed
Feb 14 05:15:34 2007
@@ -31,17 +31,25 @@
     if lastchecktimestamp:
         lastcheckdate = datetime.datetime.strptime(lastchecktimestamp, "%Y-%m-%dT%H:%M:%S")
 
+    defaultTitle = d.feed.get('title', 'RSS feed article')
+    defaultLink = d.feed.get('link', 'http://incubator.apache.org/tuscany')
+    defaultSummary = 'No information provided'
+
     for entry in d.entries:
 
-        (year, month, day, hour, minute, second, millisecond, microsecond, tzinfo) = entry.date_parsed
-        entrydate = datetime.datetime(year, month, day, hour, minute, second)
+        if entry.has_key('date'):
+            (year, month, day, hour, minute, second, millisecond, microsecond, tzinfo) =
entry.date_parsed
+            entrydate = datetime.datetime(year, month, day, hour, minute, second)
+        else:
+            entrydate = datetime.datetime.now()
+
 
         if (entrydate > lastcheckdate) :
 
-            newalertsxml += "<alert><title>" + stripXML(entry.title) + "</title>\n"
-            newalertsxml += "<address>" + entry.link + "</address>\n"
+            newalertsxml += "<alert><title>" + stripXML(entry.get('title', defaultTitle))
+ "</title>\n"
+            newalertsxml += "<address>" + entry.get('link', defaultLink) + "</address>\n"
             newalertsxml += "<date>" + entrydate.isoformat() + "</date>\n"
-            newalertsxml += "<summary>" + stripXML(entry.description) + "</summary></alert>\n"
+            newalertsxml += "<summary>" + stripXML(entry.get('description', defaultSummary))
+ "</summary></alert>\n"
     newalertsxml += "</alerts>"    
 
     return xml.etree.ElementTree.XML(newalertsxml)



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message