コード例 #1
0
ファイル: feeds.py プロジェクト: calebbrown/calebcc
    def add_item_elements(self, handler, item):
        handler.addQuickElement(u"title", item['title'])
        handler.addQuickElement(u"link", u"", {u"href": item['link'], u"rel": u"alternate"})
        if item['pubdate'] is not None:
            handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('utf-8'))

        # Author information.
        if item['author_name'] is not None:
            handler.startElement(u"author", {})
            handler.addQuickElement(u"name", item['author_name'])
            if item['author_email'] is not None:
                handler.addQuickElement(u"email", item['author_email'])
            if item['author_link'] is not None:
                handler.addQuickElement(u"uri", item['author_link'])
            handler.endElement(u"author")

        # Unique ID.
        if item['unique_id'] is not None:
            unique_id = item['unique_id']
        else:
            unique_id = get_tag_uri(item['link'], item['pubdate'])
        handler.addQuickElement(u"id", unique_id)

        # Summary.
        if item['description'] is not None:
            handler.addQuickElement(u"summary", item['description'], {u"type": u"html"})

        # Enclosure.
        if item['enclosure'] is not None:
            handler.addQuickElement(u"link", '',
                {u"rel": u"enclosure",
                 u"href": item['enclosure'].url,
                 u"length": item['enclosure'].length,
                 u"type": item['enclosure'].mime_type})

        # Categories.
        for cat in item['categories']:
            handler.addQuickElement(u"category", u"", {u"term": cat})

        # Rights.
        if item['item_copyright'] is not None:
            handler.addQuickElement(u"rights", item['item_copyright'])
コード例 #2
0
ファイル: feeds.py プロジェクト: calebbrown/calebcc
 def add_root_elements(self, handler):
     handler.addQuickElement(u"title", self.feed['title'])
     handler.addQuickElement(u"link", "", {u"rel": u"alternate", u"href": self.feed['link']})
     if self.feed['feed_url'] is not None:
         handler.addQuickElement(u"link", "", {u"rel": u"self", u"href": self.feed['feed_url']})
     handler.addQuickElement(u"id", self.feed['id'])
     handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('utf-8'))
     if self.feed['author_name'] is not None:
         handler.startElement(u"author", {})
         handler.addQuickElement(u"name", self.feed['author_name'])
         if self.feed['author_email'] is not None:
             handler.addQuickElement(u"email", self.feed['author_email'])
         if self.feed['author_link'] is not None:
             handler.addQuickElement(u"uri", self.feed['author_link'])
         handler.endElement(u"author")
     if self.feed['subtitle'] is not None:
         handler.addQuickElement(u"subtitle", self.feed['subtitle'])
     for cat in self.feed['categories']:
         handler.addQuickElement(u"category", "", {u"term": cat})
     if self.feed['feed_copyright'] is not None:
         handler.addQuickElement(u"rights", self.feed['feed_copyright'])