(self, extensions=True)
return entry
Create a RSS item and return it.
Create a RSS item and return it.
Create a RSS item and return it .
def rss_entry(self, extensions=True):
        '''Create a RSS item and return it.'''
        entry = xml_elem('item')
        if not (self.__rss_title or
                self.__rss_description or
                self.__rss_content):
            raise ValueError('Required fields not set')
        if self.__rss_title:
            title = xml_elem('title', entry)
            title.text = self.__rss_title
        if self.__rss_link:
            link = xml_elem('link', entry)
            link.text = self.__rss_link
        if self.__rss_description and self.__rss_content:
            description = xml_elem('description', entry)
            description.text = self.__rss_description
            XMLNS_CONTENT = 'http://purl.org/rss/1.0/modules/content/'
            content = xml_elem('{%s}encoded' % XMLNS_CONTENT, entry)
            content.text = CDATA(self.__rss_content['content']) \
                if self.__rss_content.get('type', '') == 'CDATA' \
                else self.__rss_content['content']
        elif self.__rss_description:
            description = xml_elem('description', entry)
            description.text = self.__rss_description
        elif self.__rss_content:
            description = xml_elem('description', entry)
            description.text = CDATA(self.__rss_content['content']) \
                if self.__rss_content.get('type', '') == 'CDATA' \
                else self.__rss_content['content']
        for a in self.__rss_author or []:
            author = xml_elem('author', entry)
            author.text = a
        if self.__rss_guid.get('guid'):
            guid = xml_elem('guid', entry)
            guid.text = self.__rss_guid['guid']
            permaLink = str(self.__rss_guid.get('permalink', False)).lower()
            guid.attrib['isPermaLink'] = permaLink
        for cat in self.__rss_category or []:
            category = xml_elem('category', entry)
            category.text = cat['value']
            if cat.get('domain'):
                category.attrib['domain'] = cat['domain']
        if self.__rss_comments:
            comments = xml_elem('comments', entry)
            comments.text = self.__rss_comments
        if self.__rss_enclosure:
            enclosure = xml_elem('enclosure', entry)
            enclosure.attrib['url'] = self.__rss_enclosure['url']
            enclosure.attrib['length'] = self.__rss_enclosure['length']
            enclosure.attrib['type'] = self.__rss_enclosure['type']
        if self.__rss_pubDate:
            pubDate = xml_elem('pubDate', entry)
            pubDate.text = formatRFC2822(self.__rss_pubDate)
        if self.__rss_source:
            source = xml_elem('source', entry, url=self.__rss_source['url'])
            source.text = self.__rss_source['title']

        if extensions:
            for ext in self.__extensions.values() or []:
                if ext.get('rss'):
                    ext['inst'].extend_rss(entry)

        return entry
def rss_entry ( self , extensions = True ) : entry = xml_elem ( 'item' ) if not ( self . __rss_title or self . __rss_description or self . __rss_content ) : raise ValueError ( 'Required fields not set' ) if self . __rss_title : title = xml_elem ( 'title' , entry ) title . text = self . __rss_title if self . __rss_link : link = xml_elem ( 'link' , entry ) link . text = self . __rss_link if self . __rss_description and self . __rss_content : description = xml_elem ( 'description' , entry ) description . text = self . __rss_description XMLNS_CONTENT = 'http://purl.org/rss/1.0/modules/content/' content = xml_elem ( '{%s}encoded' % XMLNS_CONTENT , entry ) content . text = CDATA ( self . __rss_content [ 'content' ] ) if self . __rss_content . get ( 'type' , '' ) == 'CDATA' else self . __rss_content [ 'content' ] elif self . __rss_description : description = xml_elem ( 'description' , entry ) description . text = self . __rss_description elif self . __rss_content : description = xml_elem ( 'description' , entry ) description . text = CDATA ( self . __rss_content [ 'content' ] ) if self . __rss_content . get ( 'type' , '' ) == 'CDATA' else self . __rss_content [ 'content' ] for a in self . __rss_author or [ ] : author = xml_elem ( 'author' , entry ) author . text = a if self . __rss_guid . get ( 'guid' ) : guid = xml_elem ( 'guid' , entry ) guid . text = self . __rss_guid [ 'guid' ] permaLink = str ( self . __rss_guid . get ( 'permalink' , False ) ) . lower ( ) guid . attrib [ 'isPermaLink' ] = permaLink for cat in self . __rss_category or [ ] : category = xml_elem ( 'category' , entry ) category . text = cat [ 'value' ] if cat . get ( 'domain' ) : category . attrib [ 'domain' ] = cat [ 'domain' ] if self . __rss_comments : comments = xml_elem ( 'comments' , entry ) comments . text = self . __rss_comments if self . __rss_enclosure : enclosure = xml_elem ( 'enclosure' , entry ) enclosure . attrib [ 'url' ] = self . __rss_enclosure [ 'url' ] enclosure . attrib [ 'length' ] = self . __rss_enclosure [ 'length' ] enclosure . attrib [ 'type' ] = self . __rss_enclosure [ 'type' ] if self . __rss_pubDate : pubDate = xml_elem ( 'pubDate' , entry ) pubDate . text = formatRFC2822 ( self . __rss_pubDate ) if self . __rss_source : source = xml_elem ( 'source' , entry , url = self . __rss_source [ 'url' ] ) source . text = self . __rss_source [ 'title' ] if extensions : for ext in self . __extensions . values ( ) or [ ] : if ext . get ( 'rss' ) : ext [ 'inst' ] . extend_rss ( entry ) return entry