Potential strengthing of feed file writing on UNIX
authorLindsey Smith <lindsey.smith@gmail.com>
Fri, 4 Mar 2011 16:56:07 +0000 (08:56 -0800)
committerLindsey Smith <lindsey.smith@gmail.com>
Fri, 4 Mar 2011 16:56:07 +0000 (08:56 -0800)
Handle via links with no title attribute

rss2email.py

index d178bad30f159bb5d2e4787d2f4828ce3d5b6d2a..0dc2d04b3521a886f2e324e5a38e69e896c09fee 100644 (file)
@@ -507,7 +507,11 @@ def unlock(feeds, feedfileObject):
        if not unix: 
                pickle.dump(feeds, open(feedfile, 'w'))
        else:   
-               pickle.dump(feeds, open(feedfile+'.tmp', 'w'))
+               fd = open(feedfile+'.tmp', 'w')
+               pickle.dump(feeds, fd)
+               fd.flush()
+               os.fsync(fd.fileno())
+               fd.close()
                os.rename(feedfile+'.tmp', feedfile)
                fcntl.flock(feedfileObject.fileno(), fcntl.LOCK_UN)
 
@@ -731,7 +735,10 @@ def run(num=None):
                                                                if ('rel' in extralink) and extralink['rel'] == u'via':
                                                                        extraurl = extralink['href']
                                                                        extraurl = extraurl.replace('http://www.google.com/reader/public/atom/', 'http://www.google.com/reader/view/')
-                                                                       content += '<br/>Via: <a href="'+extraurl+'">'+extralink['title']+'</a>\n'
+                                                                       viatitle = extraurl
+                                                                       if ('title' in extralink):
+                                                                           viatitle = extralink['title']
+                                                                       content += '<br/>Via: <a href="'+extraurl+'">'+viatitle+'</a>\n'
                                                content += '</p></div>\n'
                                                content += "\n\n</body></html>"
                                        else: