From 6888a046362316f98fb3aaf2982ca246ad724f30 Mon Sep 17 00:00:00 2001 From: Aaron Kavlie Date: Thu, 12 Apr 2012 19:38:59 -0700 Subject: [PATCH] Issue #311 Catch BeautifulSoup ImportError. --- pelican/tools/pelican_import.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py index 57c4fc22..a4d64c67 100755 --- a/pelican/tools/pelican_import.py +++ b/pelican/tools/pelican_import.py @@ -13,7 +13,12 @@ from pelican.utils import slugify 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