1
0
Fork 0
forked from github/pelican

Warn user in case of missing title. Fixes #440.

When a WP XML file is imported, items with missing title are generated with a
title which is probably not the good one (instead of being dropped), and a
warning is displayed to the user.
This commit is contained in:
Rogdham 2013-04-13 20:37:26 +01:00
commit a4c16e1b53

View file

@ -14,10 +14,14 @@ import re
import subprocess
import sys
import time
import logging
from codecs import open
from pelican.utils import slugify
from pelican.log import init
logger = logging.getLogger(__name__)
def decode_wp_content(content, br=True):
@ -114,7 +118,8 @@ def wp2fields(xml):
# Use HTMLParser due to issues with BeautifulSoup 3
title = HTMLParser().unescape(item.title.contents[0])
except IndexError:
continue
title = 'No title [%s]' % item.find('post_name').string
logger.warn('Post "%s" is lacking a proper title' % title)
content = item.find('encoded').string
filename = item.find('post_name').string
@ -492,6 +497,8 @@ def main():
elif input_type == 'feed':
fields = feed2fields(args.input)
init() # init logging
fields2pelican(fields, args.markup, args.output,
dircat=args.dircat or False,
strip_raw=args.strip_raw or False,