(self, extensions=True)
return feed, doc
Create an RSS feed xml structure containing all previously set
        fields.

        :returns: Tuple containing the feed root element and the element tree.
Create an RSS feed xml structure containing all previously set
        fields.
Create an RSS feed xml structure containing all previously set fields .
def _create_rss(self, extensions=True):
        '''Create an RSS feed xml structure containing all previously set
        fields.

        :returns: Tuple containing the feed root element and the element tree.
        '''
        nsmap = dict()
        if extensions:
            for ext in self.__extensions.values() or []:
                if ext.get('rss'):
                    nsmap.update(ext['inst'].extend_ns())

        nsmap.update({'atom':  'http://www.w3.org/2005/Atom',
                      'content': 'http://purl.org/rss/1.0/modules/content/'})

        feed = xml_elem('rss', version='2.0', nsmap=nsmap)
        channel = xml_elem('channel', feed)
        if not (self.__rss_title and
                self.__rss_link and
                self.__rss_description):
            missing = ([] if self.__rss_title else ['title']) + \
                      ([] if self.__rss_link else ['link']) + \
                      ([] if self.__rss_description else ['description'])
            missing = ', '.join(missing)
            raise ValueError('Required fields not set (%s)' % missing)
        title = xml_elem('title', channel)
        title.text = self.__rss_title
        link = xml_elem('link', channel)
        link.text = self.__rss_link
        desc = xml_elem('description', channel)
        desc.text = self.__rss_description
        for ln in self.__atom_link or []:
            # It is recommended to include a atom self link in rss documents…
            if ln.get('rel') == 'self':
                selflink = xml_elem('{http://www.w3.org/2005/Atom}link',
                                    channel, href=ln['href'], rel='self')
                if ln.get('type'):
                    selflink.attrib['type'] = ln['type']
                if ln.get('hreflang'):
                    selflink.attrib['hreflang'] = ln['hreflang']
                if ln.get('title'):
                    selflink.attrib['title'] = ln['title']
                if ln.get('length'):
                    selflink.attrib['length'] = ln['length']
                break
        if self.__rss_category:
            for cat in self.__rss_category:
                category = xml_elem('category', channel)
                category.text = cat['value']
                if cat.get('domain'):
                    category.attrib['domain'] = cat['domain']
        if self.__rss_cloud:
            cloud = xml_elem('cloud', channel)
            cloud.attrib['domain'] = self.__rss_cloud.get('domain')
            cloud.attrib['port'] = self.__rss_cloud.get('port')
            cloud.attrib['path'] = self.__rss_cloud.get('path')
            cloud.attrib['registerProcedure'] = self.__rss_cloud.get(
                    'registerProcedure')
            cloud.attrib['protocol'] = self.__rss_cloud.get('protocol')
        if self.__rss_copyright:
            copyright = xml_elem('copyright', channel)
            copyright.text = self.__rss_copyright
        if self.__rss_docs:
            docs = xml_elem('docs', channel)
            docs.text = self.__rss_docs
        if self.__rss_generator:
            generator = xml_elem('generator', channel)
            generator.text = self.__rss_generator
        if self.__rss_image:
            image = xml_elem('image', channel)
            url = xml_elem('url', image)
            url.text = self.__rss_image.get('url')
            title = xml_elem('title', image)
            title.text = self.__rss_image.get('title', self.__rss_title)
            link = xml_elem('link', image)
            link.text = self.__rss_image.get('link', self.__rss_link)
            if self.__rss_image.get('width'):
                width = xml_elem('width', image)
                width.text = self.__rss_image.get('width')
            if self.__rss_image.get('height'):
                height = xml_elem('height', image)
                height.text = self.__rss_image.get('height')
            if self.__rss_image.get('description'):
                description = xml_elem('description', image)
                description.text = self.__rss_image.get('description')
        if self.__rss_language:
            language = xml_elem('language', channel)
            language.text = self.__rss_language
        if self.__rss_lastBuildDate:
            lastBuildDate = xml_elem('lastBuildDate', channel)

            lastBuildDate.text = formatRFC2822(self.__rss_lastBuildDate)
        if self.__rss_managingEditor:
            managingEditor = xml_elem('managingEditor', channel)
            managingEditor.text = self.__rss_managingEditor
        if self.__rss_pubDate:
            pubDate = xml_elem('pubDate', channel)
            pubDate.text = formatRFC2822(self.__rss_pubDate)
        if self.__rss_rating:
            rating = xml_elem('rating', channel)
            rating.text = self.__rss_rating
        if self.__rss_skipHours:
            skipHours = xml_elem('skipHours', channel)
            for h in self.__rss_skipHours:
                hour = xml_elem('hour', skipHours)
                hour.text = str(h)
        if self.__rss_skipDays:
            skipDays = xml_elem('skipDays', channel)
            for d in self.__rss_skipDays:
                day = xml_elem('day', skipDays)
                day.text = d
        if self.__rss_textInput:
            textInput = xml_elem('textInput', channel)
            textInput.attrib['title'] = self.__rss_textInput.get('title')
            textInput.attrib['description'] = \
                self.__rss_textInput.get('description')
            textInput.attrib['name'] = self.__rss_textInput.get('name')
            textInput.attrib['link'] = self.__rss_textInput.get('link')
        if self.__rss_ttl:
            ttl = xml_elem('ttl', channel)
            ttl.text = str(self.__rss_ttl)
        if self.__rss_webMaster:
            webMaster = xml_elem('webMaster', channel)
            webMaster.text = self.__rss_webMaster

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

        for entry in self.__feed_entries:
            item = entry.rss_entry()
            channel.append(item)

        doc = etree.ElementTree(feed)
        return feed, doc
def _create_rss ( self , extensions = True ) : nsmap = dict ( ) if extensions : for ext in self . __extensions . values ( ) or [ ] : if ext . get ( 'rss' ) : nsmap . update ( ext [ 'inst' ] . extend_ns ( ) ) nsmap . update ( { 'atom' : 'http://www.w3.org/2005/Atom' , 'content' : 'http://purl.org/rss/1.0/modules/content/' } ) feed = xml_elem ( 'rss' , version = '2.0' , nsmap = nsmap ) channel = xml_elem ( 'channel' , feed ) if not ( self . __rss_title and self . __rss_link and self . __rss_description ) : missing = ( [ ] if self . __rss_title else [ 'title' ] ) + ( [ ] if self . __rss_link else [ 'link' ] ) + ( [ ] if self . __rss_description else [ 'description' ] ) missing = ', ' . join ( missing ) raise ValueError ( 'Required fields not set (%s)' % missing ) title = xml_elem ( 'title' , channel ) title . text = self . __rss_title link = xml_elem ( 'link' , channel ) link . text = self . __rss_link desc = xml_elem ( 'description' , channel ) desc . text = self . __rss_description for ln in self . __atom_link or [ ] : # It is recommended to include a atom self link in rss documents… if ln . get ( 'rel' ) == 'self' : selflink = xml_elem ( '{http://www.w3.org/2005/Atom}link' , channel , href = ln [ 'href' ] , rel = 'self' ) if ln . get ( 'type' ) : selflink . attrib [ 'type' ] = ln [ 'type' ] if ln . get ( 'hreflang' ) : selflink . attrib [ 'hreflang' ] = ln [ 'hreflang' ] if ln . get ( 'title' ) : selflink . attrib [ 'title' ] = ln [ 'title' ] if ln . get ( 'length' ) : selflink . attrib [ 'length' ] = ln [ 'length' ] break if self . __rss_category : for cat in self . __rss_category : category = xml_elem ( 'category' , channel ) category . text = cat [ 'value' ] if cat . get ( 'domain' ) : category . attrib [ 'domain' ] = cat [ 'domain' ] if self . __rss_cloud : cloud = xml_elem ( 'cloud' , channel ) cloud . attrib [ 'domain' ] = self . __rss_cloud . get ( 'domain' ) cloud . attrib [ 'port' ] = self . __rss_cloud . get ( 'port' ) cloud . attrib [ 'path' ] = self . __rss_cloud . get ( 'path' ) cloud . attrib [ 'registerProcedure' ] = self . __rss_cloud . get ( 'registerProcedure' ) cloud . attrib [ 'protocol' ] = self . __rss_cloud . get ( 'protocol' ) if self . __rss_copyright : copyright = xml_elem ( 'copyright' , channel ) copyright . text = self . __rss_copyright if self . __rss_docs : docs = xml_elem ( 'docs' , channel ) docs . text = self . __rss_docs if self . __rss_generator : generator = xml_elem ( 'generator' , channel ) generator . text = self . __rss_generator if self . __rss_image : image = xml_elem ( 'image' , channel ) url = xml_elem ( 'url' , image ) url . text = self . __rss_image . get ( 'url' ) title = xml_elem ( 'title' , image ) title . text = self . __rss_image . get ( 'title' , self . __rss_title ) link = xml_elem ( 'link' , image ) link . text = self . __rss_image . get ( 'link' , self . __rss_link ) if self . __rss_image . get ( 'width' ) : width = xml_elem ( 'width' , image ) width . text = self . __rss_image . get ( 'width' ) if self . __rss_image . get ( 'height' ) : height = xml_elem ( 'height' , image ) height . text = self . __rss_image . get ( 'height' ) if self . __rss_image . get ( 'description' ) : description = xml_elem ( 'description' , image ) description . text = self . __rss_image . get ( 'description' ) if self . __rss_language : language = xml_elem ( 'language' , channel ) language . text = self . __rss_language if self . __rss_lastBuildDate : lastBuildDate = xml_elem ( 'lastBuildDate' , channel ) lastBuildDate . text = formatRFC2822 ( self . __rss_lastBuildDate ) if self . __rss_managingEditor : managingEditor = xml_elem ( 'managingEditor' , channel ) managingEditor . text = self . __rss_managingEditor if self . __rss_pubDate : pubDate = xml_elem ( 'pubDate' , channel ) pubDate . text = formatRFC2822 ( self . __rss_pubDate ) if self . __rss_rating : rating = xml_elem ( 'rating' , channel ) rating . text = self . __rss_rating if self . __rss_skipHours : skipHours = xml_elem ( 'skipHours' , channel ) for h in self . __rss_skipHours : hour = xml_elem ( 'hour' , skipHours ) hour . text = str ( h ) if self . __rss_skipDays : skipDays = xml_elem ( 'skipDays' , channel ) for d in self . __rss_skipDays : day = xml_elem ( 'day' , skipDays ) day . text = d if self . __rss_textInput : textInput = xml_elem ( 'textInput' , channel ) textInput . attrib [ 'title' ] = self . __rss_textInput . get ( 'title' ) textInput . attrib [ 'description' ] = self . __rss_textInput . get ( 'description' ) textInput . attrib [ 'name' ] = self . __rss_textInput . get ( 'name' ) textInput . attrib [ 'link' ] = self . __rss_textInput . get ( 'link' ) if self . __rss_ttl : ttl = xml_elem ( 'ttl' , channel ) ttl . text = str ( self . __rss_ttl ) if self . __rss_webMaster : webMaster = xml_elem ( 'webMaster' , channel ) webMaster . text = self . __rss_webMaster if extensions : for ext in self . __extensions . values ( ) or [ ] : if ext . get ( 'rss' ) : ext [ 'inst' ] . extend_rss ( feed ) for entry in self . __feed_entries : item = entry . rss_entry ( ) channel . append ( item ) doc = etree . ElementTree ( feed ) return feed , doc