def import_entries(self, items):
        """
        Loops over items and find entry to import,
        an entry need to have 'post_type' set to 'post' and
        have content.
        """
        self.write_out(self.style.STEP('- Importing entries\n'))

        for item_node in items:
            title = (item_node.find('title').text or '')[:255]
            post_type = item_node.find('{%s}post_type' % WP_NS).text
            content = item_node.find(
                '{http://purl.org/rss/1.0/modules/content/}encoded').text

            if post_type == 'post' and content and title:
                self.write_out('> %s... ' % title)
                entry, created = self.import_entry(title, content, item_node)
                if created:
                    self.write_out(self.style.ITEM('OK\n'))
                    image_id = self.find_image_id(
                        item_node.findall('{%s}postmeta' % WP_NS))
                    if image_id:
                        self.import_image(entry, items, image_id)
                    self.import_comments(entry, item_node.findall(
                        '{%s}comment' % WP_NS))
                else:
                    self.write_out(self.style.NOTICE(
                        'SKIPPED (already imported)\n'))
            else:
                self.write_out('> %s... ' % title, 2)
                self.write_out(self.style.NOTICE('SKIPPED (not a post)\n'), 2)
def import_entries ( self , items ) : self . write_out ( self . style . STEP ( '- Importing entries\n' ) ) for item_node in items : title = ( item_node . find ( 'title' ) . text or '' ) [ : 255 ] post_type = item_node . find ( '{%s}post_type' % WP_NS ) . text content = item_node . find ( '{http://purl.org/rss/1.0/modules/content/}encoded' ) . text if post_type == 'post' and content and title : self . write_out ( '> %s... ' % title ) entry , created = self . import_entry ( title , content , item_node ) if created : self . write_out ( self . style . ITEM ( 'OK\n' ) ) image_id = self . find_image_id ( item_node . findall ( '{%s}postmeta' % WP_NS ) ) if image_id : self . import_image ( entry , items , image_id ) self . import_comments ( entry , item_node . findall ( '{%s}comment' % WP_NS ) ) else : self . write_out ( self . style . NOTICE ( 'SKIPPED (already imported)\n' ) ) else : self . write_out ( '> %s... ' % title , 2 ) self . write_out ( self . style . NOTICE ( 'SKIPPED (not a post)\n' ) , 2 )
Loops over items and find entry to import,
        an entry need to have 'post_type' set to 'post' and
        have content.