5 # Downloads feeds from the URLs specified and generates the XHTML files.
10 # standard python modules
13 import XMLParse2 as XMLParse, XMLWriter, CacheHandler
14 # planetUCC output plugins
15 import XHTMLWriter, RSS2Writer, RSS1Writer
17 # step 1: read in the config and check each object from cache
18 cache = CacheHandler.CacheHandler()
21 for feed in open('feedlist').readlines():
22 if feed.strip()[0] != '#':
23 storage = feed.strip().split('\t')
24 name, feed = storage[0], storage[-1]
26 feeds.append((name, feed, cache.getBlog(name, feed)))
28 sys.stderr.write('DEBUG: update-planet: something went wrong retrieving feed\n')
30 # step 2: process each feed
34 # XMLParse2 takes two paramaters, a URL and a CacheObject
35 blog = XMLParse.XMLParse(feed[1], feed[2]).parse()
37 blog.blogTitle = feed[0]
38 blog.feedURL = feed[1]
40 # check the old copy of the cache, vs the new copy
41 if not feed[2] or not feed[2].cache or not blog or not blog.cache or feed[2].cache != blog.cache:
43 # write the cache back down to disk
49 sys.stderr.write('PlanetUCC: no objects have changed in the cache, not updating\n')
52 # step 3: sift the feeds
53 xmlwriter = XMLWriter.XMLWriter(blogs)
55 # step 4: write feed to disk
57 codecs.open('planet.html', 'wb', 'utf-8').write(xmlwriter.write(XHTMLWriter.XHTMLWriter))
59 sys.stderr.write('DEBUG: update-planet: could not write planet.html, aborting\n')
62 codecs.open('rss2.xml', 'wb', 'utf-8').write(xmlwriter.write(RSS2Writer.RSS2Writer))
64 sys.stderr.write('DEBUG: update-planet: could not write rss2.xml, aborting\n')
67 codecs.open('rss1.xml', 'wb', 'utf-8').write(xmlwriter.write(RSS1Writer.RSS1Writer))
69 sys.stderr.write('DEBUG: update-planet: could not write rss1.xml, aborting\n')