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.blogURL = blog.blogURL
18 self.imageURL = blog.imageURL
19 self.imageLink = blog.imageLink
20 self.contents = item.contents
23 def __init__(self, date):
24 self.planetDate = date
28 def __init__(self, bloglist):
29 self.__bloglist__ = bloglist
30 self.__tainted__ = True
33 def append(self, blog):
34 self.__bloglist__.append(blog)
35 self.__tainted__ = True
37 def __getNext__(self, bloglist):
38 "Returns a PlanetItem reaped from a bloglist"
42 if len(blog.items) > 0 and blog.items[0].itemDate > latestTime:
43 latestTime = blog.items[0].itemDate
45 if holdingBlog == None:
47 item = holdingBlog.items.pop(0)
48 return PlanetItem(holdingBlog, item)
52 # we need to sort the blogs into a single news feed
53 # copy the bloglist to a working symbol
54 bloglist = self.__bloglist__ + []
59 lastItem = self.__getNext__(bloglist)
62 # this checks to see if it's a new day
63 if time.localtime(lastItem.itemDate)[6] != lastDate:
64 lastDate = time.localtime(lastItem.itemDate)[6]
65 workingDate = PlanetDate(lastItem.itemDate)
66 self.dates.append(workingDate)
67 # append the item to the current date
68 workingDate.items.append(lastItem)
69 self.__tainted__ = False
74 def __init__(self, bloglist):
76 self.planet = Planet(bloglist)
77 self.items = self.planet.sort()
79 def write(self, doctype):
80 # doctype should be something like XHTMLWriter.XHTMLWriter
81 writer = doctype(self.items)
83 output = writer.write()