Permalink
Browse files

Issue #311

Catch BeautifulSoup ImportError.
  • Loading branch information...
akavlie committed Apr 13, 2012
1 parent b9973bc commit 6888a046362316f98fb3aaf2982ca246ad724f30
Showing with 13 additions and 2 deletions.
  1. +13 −2 pelican/tools/pelican_import.py
@@ -13,7 +13,12 @@
def wp2fields(xml):
"""Opens a wordpress XML file, and yield pelican fields"""
- from BeautifulSoup import BeautifulStoneSoup
+ try:
+ from BeautifulSoup import BeautifulStoneSoup
+ except ImportError:
+ error = 'Missing dependency ' + \
+ '"BeautifulSoup" required to import Wordpress files.'
+ sys.exit(error)
xmlfile = open(xml, encoding='utf-8').read()
soup = BeautifulStoneSoup(xmlfile)
@@ -40,7 +45,13 @@ def wp2fields(xml):
def dc2fields(file):
"""Opens a Dotclear export file, and yield pelican fields"""
- from BeautifulSoup import BeautifulStoneSoup
+ try:
+ from BeautifulSoup import BeautifulStoneSoup
+ except ImportError:
+ error = 'Missing dependency ' + \
+ '"BeautifulSoup" required to import Dotclear files.'
+ sys.exit(error)
+
in_cat = False
in_post = False

2 comments on commit 6888a04

@tshepang

This comment has been minimized.

Show comment Hide comment
@tshepang

tshepang Apr 18, 2012

nit: 2nd assignment looks better than 1st one

error = 'Missing dependency ' + \
        '"BeautifulSoup" required to import Dotclear files.'
error = ('Missing dependency '
         '"BeautifulSoup" required to import Dotclear files.')

nit: 2nd assignment looks better than 1st one

error = 'Missing dependency ' + \
        '"BeautifulSoup" required to import Dotclear files.'
error = ('Missing dependency '
         '"BeautifulSoup" required to import Dotclear files.')
@akavlie

This comment has been minimized.

Show comment Hide comment
@akavlie

akavlie Apr 19, 2012

Owner

agreed, adding another commit for that momentarily.

Owner

akavlie replied Apr 19, 2012

agreed, adding another commit for that momentarily.

Please sign in to comment.