4 # Generate arbitrary XML files
12 def __init__(self, blog, item):
13 self.itemTitle = item.itemTitle
14 self.itemURL = item.itemURL
15 self.itemDate = item.itemDate
16 self.blogTitle = blog.blogTitle
17 self.blogName = blog.blogName
18 self.blogURL = blog.blogURL
19 self.imageURL = blog.imageURL
20 self.imageLink = blog.imageLink
21 self.contents = item.contents
22 self.commentsURL = item.commentsURL
25 def __init__(self, date):
26 self.planetDate = date
30 def __init__(self, bloglist):
31 self.__bloglist__ = bloglist
32 self.__tainted__ = True
35 def append(self, blog):
36 self.__bloglist__.append(blog)
37 self.__tainted__ = True
39 def __getNext__(self, bloglist):
40 "Returns a PlanetItem reaped from a bloglist"
44 if len(blog.items) > 0 and blog.items[0].itemDate > latestTime:
45 latestTime = blog.items[0].itemDate
47 if holdingBlog == None:
49 item = holdingBlog.items.pop(0)
50 return PlanetItem(holdingBlog, item)
54 # we need to sort the blogs into a single news feed
55 # copy the bloglist to a working symbol
56 bloglist = self.__bloglist__ + []
61 lastItem = self.__getNext__(bloglist)
64 # this checks to see if it's a new day
65 if time.localtime(lastItem.itemDate)[6] != lastDate:
66 lastDate = time.localtime(lastItem.itemDate)[6]
67 workingDate = PlanetDate(lastItem.itemDate)
68 self.dates.append(workingDate)
69 # append the item to the current date
70 workingDate.items.append(lastItem)
71 self.__tainted__ = False
76 def __init__(self, bloglist):
78 self.planet = Planet(bloglist)
79 self.items = self.planet.sort()
81 def write(self, doctype):
82 # doctype should be something like XHTMLWriter.XHTMLWriter
83 writer = doctype(self.items)
85 output = writer.write()