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
24 def __init__(self, date):
25 self.planetDate = date
29 def __init__(self, bloglist):
30 self.__bloglist__ = bloglist
31 self.__tainted__ = True
34 def append(self, blog):
35 self.__bloglist__.append(blog)
36 self.__tainted__ = True
38 def __getNext__(self, bloglist):
39 "Returns a PlanetItem reaped from a bloglist"
43 if len(blog.items) > 0 and blog.items[0].itemDate > latestTime:
44 latestTime = blog.items[0].itemDate
46 if holdingBlog == None:
48 item = holdingBlog.items.pop(0)
49 return PlanetItem(holdingBlog, item)
53 # we need to sort the blogs into a single news feed
54 # copy the bloglist to a working symbol
55 bloglist = self.__bloglist__ + []
60 lastItem = self.__getNext__(bloglist)
63 # this checks to see if it's a new day
64 if time.localtime(lastItem.itemDate)[6] != lastDate:
65 lastDate = time.localtime(lastItem.itemDate)[6]
66 workingDate = PlanetDate(lastItem.itemDate)
67 self.dates.append(workingDate)
68 # append the item to the current date
69 workingDate.items.append(lastItem)
70 self.__tainted__ = False
75 def __init__(self, bloglist):
77 self.planet = Planet(bloglist)
78 self.items = self.planet.sort()
80 def write(self, doctype):
81 # doctype should be something like XHTMLWriter.XHTMLWriter
82 writer = doctype(self.items)
84 output = writer.write()