def serialize(self): if self.use_utf8: encoder = EntityEncoderU() else: encoder = EntityEncoder() serialized = u'' serialized = serialized + "<link" if self.item == 'blurb': serialized = serialized + ' type="blurb"' serialized = serialized + ">\n" serialized = serialized + '<time value="' serialized = serialized + "%f" % self.time serialized = serialized + '">' serialized = serialized + encoder.encode_chars(TimeFormatter().format_time(self.time)) serialized = serialized + "</time>\n" serialized = serialized + "<keywords>" + encoder.encode_chars(self.keywords) + "</keywords>\n" if not self.item == 'blurb': serialized = serialized + "<url>"+encoder.encode_chars(self.item)+"</url>\n" serialized = serialized + "<nick>"+encoder.encode_chars(self.nick)+"</nick>\n" if self.title != '': serialized = serialized + "<title>"+encoder.encode_chars(self.title)+"</title>\n" for c in self.comments: nick = c[0] comment = c[1] serialized = serialized + self.serialize_comment(nick,comment,encoder) serialized = serialized + "</link>\n" return serialized
def serialize(self): if self.use_utf8: encoder = EntityEncoderU() serialized=u'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE churn>\n' else: encoder = EntityEncoder() serialized=u'<?xml version="1.0" encoding="iso-8859-1"?>\n<!DOCTYPE churn>\n' if self.get_stylesheet()!="": serialized = serialized + '<?xml-stylesheet href="'+\ encoder.encode_chars(self.get_stylesheet())+\ '" type="'+\ self.get_stylesheettype()+'"?>'+"\n" serialized = serialized + "<churn>\n" serialized = serialized + '<last-updated value="' serialized = serialized + "%f" % self.updatetime serialized = serialized + '">' serialized = serialized + encoder.encode_chars(TimeFormatter().format_time(self.updatetime))+"</last-updated>\n" serialized = serialized + '<relative-uri-stub value="' + encoder.encode_chars(self.get_relative_uri()) + '"/>'+"\n" serialized = serialized + '<itemcount value="' serialized = serialized + "%d" % self.get_entry_count() serialized = serialized + '" />\n' serialized = serialized + "<topic>"+encoder.encode_chars(self.topic)+"</topic>\n" for x in self._timesorted_labels(): entry = self.get_entry(x) serialized = serialized + entry.serialize() serialized = serialized + "</churn>" if self.use_utf8: return serialized.encode('utf-8') else: return serialized.encode('latin-1')