getpelican/pelican — pull request #879 by joeshaw (2013-12-04 14:47:29+00:00)
Title: Wordpress import blows up on empty <wp:post_name>

Importing from a Wordpress XML export file:

```
WARNING: Post "No title [None]" is lacking a proper title
Traceback (most recent call last):
File "/private/tmp/virtualenv/bin/pelican-import", line 8, in
load_entry_point('pelican==3.2', 'console_scripts', 'pelican-import')()
File "/private/tmp/virtualenv/lib/python2.7/site-packages/pelican/tools/pelican_import.py", line 518, in main
disable_slugs=args.disable_slugs or False)
File "/private/tmp/virtualenv/lib/python2.7/site-packages/pelican/tools/pelican_import.py", line 379, in fields2pelican
filename = os.path.basename(filename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 112, in basename
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
```

This is because I have several old posts with an empty `` tag:

```xml

```

Adding

```python
if filename is None:
filename = item.find('post_id').string
```

after the `filename` assignment in `wp2fields()` in `pelican_import.py` seems to have worked for me.