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

        :returns: Tuple containing the feed root element and the element tree.
Create a ATOM feed xml structure containing all previously set
        fields.
Create a ATOM feed xml structure containing all previously set fields .
def _create_atom(self, extensions=True):
        '''Create a ATOM 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('atom'):
                    nsmap.update(ext['inst'].extend_ns())

        feed = xml_elem('feed',
                        xmlns='http://www.w3.org/2005/Atom',
                        nsmap=nsmap)
        if self.__atom_feed_xml_lang:
            feed.attrib['{http://www.w3.org/XML/1998/namespace}lang'] = \
                    self.__atom_feed_xml_lang

        if not (self.__atom_id and self.__atom_title and self.__atom_updated):
            missing = ([] if self.__atom_title else ['title']) + \
                      ([] if self.__atom_id else ['id']) + \
                      ([] if self.__atom_updated else ['updated'])
            missing = ', '.join(missing)
            raise ValueError('Required fields not set (%s)' % missing)
        id = xml_elem('id', feed)
        id.text = self.__atom_id
        title = xml_elem('title', feed)
        title.text = self.__atom_title
        updated = xml_elem('updated', feed)
        updated.text = self.__atom_updated.isoformat()

        # Add author elements
        for a in self.__atom_author or []:
            # Atom requires a name. Skip elements without.
            if not a.get('name'):
                continue
            author = xml_elem('author', feed)
            name = xml_elem('name', author)
            name.text = a.get('name')
            if a.get('email'):
                email = xml_elem('email', author)
                email.text = a.get('email')
            if a.get('uri'):
                uri = xml_elem('uri', author)
                uri.text = a.get('uri')

        for l in self.__atom_link or []:
            link = xml_elem('link', feed, href=l['href'])
            if l.get('rel'):
                link.attrib['rel'] = l['rel']
            if l.get('type'):
                link.attrib['type'] = l['type']
            if l.get('hreflang'):
                link.attrib['hreflang'] = l['hreflang']
            if l.get('title'):
                link.attrib['title'] = l['title']
            if l.get('length'):
                link.attrib['length'] = l['length']

        for c in self.__atom_category or []:
            cat = xml_elem('category', feed, term=c['term'])
            if c.get('scheme'):
                cat.attrib['scheme'] = c['scheme']
            if c.get('label'):
                cat.attrib['label'] = c['label']

        # Add author elements
        for c in self.__atom_contributor or []:
            # Atom requires a name. Skip elements without.
            if not c.get('name'):
                continue
            contrib = xml_elem('contributor', feed)
            name = xml_elem('name', contrib)
            name.text = c.get('name')
            if c.get('email'):
                email = xml_elem('email', contrib)
                email.text = c.get('email')
            if c.get('uri'):
                uri = xml_elem('uri', contrib)
                uri.text = c.get('uri')

        if self.__atom_generator and self.__atom_generator.get('value'):
            generator = xml_elem('generator', feed)
            generator.text = self.__atom_generator['value']
            if self.__atom_generator.get('uri'):
                generator.attrib['uri'] = self.__atom_generator['uri']
            if self.__atom_generator.get('version'):
                generator.attrib['version'] = self.__atom_generator['version']

        if self.__atom_icon:
            icon = xml_elem('icon', feed)
            icon.text = self.__atom_icon

        if self.__atom_logo:
            logo = xml_elem('logo', feed)
            logo.text = self.__atom_logo

        if self.__atom_rights:
            rights = xml_elem('rights', feed)
            rights.text = self.__atom_rights

        if self.__atom_subtitle:
            subtitle = xml_elem('subtitle', feed)
            subtitle.text = self.__atom_subtitle

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

        for entry in self.__feed_entries:
            entry = entry.atom_entry()
            feed.append(entry)

        doc = etree.ElementTree(feed)
        return feed, doc
def _create_atom ( self , extensions = True ) : nsmap = dict ( ) if extensions : for ext in self . __extensions . values ( ) or [ ] : if ext . get ( 'atom' ) : nsmap . update ( ext [ 'inst' ] . extend_ns ( ) ) feed = xml_elem ( 'feed' , xmlns = 'http://www.w3.org/2005/Atom' , nsmap = nsmap ) if self . __atom_feed_xml_lang : feed . attrib [ '{http://www.w3.org/XML/1998/namespace}lang' ] = self . __atom_feed_xml_lang if not ( self . __atom_id and self . __atom_title and self . __atom_updated ) : missing = ( [ ] if self . __atom_title else [ 'title' ] ) + ( [ ] if self . __atom_id else [ 'id' ] ) + ( [ ] if self . __atom_updated else [ 'updated' ] ) missing = ', ' . join ( missing ) raise ValueError ( 'Required fields not set (%s)' % missing ) id = xml_elem ( 'id' , feed ) id . text = self . __atom_id title = xml_elem ( 'title' , feed ) title . text = self . __atom_title updated = xml_elem ( 'updated' , feed ) updated . text = self . __atom_updated . isoformat ( ) # Add author elements for a in self . __atom_author or [ ] : # Atom requires a name. Skip elements without. if not a . get ( 'name' ) : continue author = xml_elem ( 'author' , feed ) name = xml_elem ( 'name' , author ) name . text = a . get ( 'name' ) if a . get ( 'email' ) : email = xml_elem ( 'email' , author ) email . text = a . get ( 'email' ) if a . get ( 'uri' ) : uri = xml_elem ( 'uri' , author ) uri . text = a . get ( 'uri' ) for l in self . __atom_link or [ ] : link = xml_elem ( 'link' , feed , href = l [ 'href' ] ) if l . get ( 'rel' ) : link . attrib [ 'rel' ] = l [ 'rel' ] if l . get ( 'type' ) : link . attrib [ 'type' ] = l [ 'type' ] if l . get ( 'hreflang' ) : link . attrib [ 'hreflang' ] = l [ 'hreflang' ] if l . get ( 'title' ) : link . attrib [ 'title' ] = l [ 'title' ] if l . get ( 'length' ) : link . attrib [ 'length' ] = l [ 'length' ] for c in self . __atom_category or [ ] : cat = xml_elem ( 'category' , feed , term = c [ 'term' ] ) if c . get ( 'scheme' ) : cat . attrib [ 'scheme' ] = c [ 'scheme' ] if c . get ( 'label' ) : cat . attrib [ 'label' ] = c [ 'label' ] # Add author elements for c in self . __atom_contributor or [ ] : # Atom requires a name. Skip elements without. if not c . get ( 'name' ) : continue contrib = xml_elem ( 'contributor' , feed ) name = xml_elem ( 'name' , contrib ) name . text = c . get ( 'name' ) if c . get ( 'email' ) : email = xml_elem ( 'email' , contrib ) email . text = c . get ( 'email' ) if c . get ( 'uri' ) : uri = xml_elem ( 'uri' , contrib ) uri . text = c . get ( 'uri' ) if self . __atom_generator and self . __atom_generator . get ( 'value' ) : generator = xml_elem ( 'generator' , feed ) generator . text = self . __atom_generator [ 'value' ] if self . __atom_generator . get ( 'uri' ) : generator . attrib [ 'uri' ] = self . __atom_generator [ 'uri' ] if self . __atom_generator . get ( 'version' ) : generator . attrib [ 'version' ] = self . __atom_generator [ 'version' ] if self . __atom_icon : icon = xml_elem ( 'icon' , feed ) icon . text = self . __atom_icon if self . __atom_logo : logo = xml_elem ( 'logo' , feed ) logo . text = self . __atom_logo if self . __atom_rights : rights = xml_elem ( 'rights' , feed ) rights . text = self . __atom_rights if self . __atom_subtitle : subtitle = xml_elem ( 'subtitle' , feed ) subtitle . text = self . __atom_subtitle if extensions : for ext in self . __extensions . values ( ) or [ ] : if ext . get ( 'atom' ) : ext [ 'inst' ] . extend_atom ( feed ) for entry in self . __feed_entries : entry = entry . atom_entry ( ) feed . append ( entry ) doc = etree . ElementTree ( feed ) return feed , doc