pandoc is optional

This commit is contained in:
Alexis Metaireau 2012-06-10 13:27:36 +02:00
commit 7c48937ea2
2 changed files with 16 additions and 15 deletions

View file

@ -247,14 +247,15 @@ def fields2pelican(fields, out_markup, output_path, dircat=False, strip_raw=Fals
try:
rc = subprocess.call(cmd, shell=True)
if rc < 0:
print("Child was terminated by signal %d" % -rc)
exit()
error = "Child was terminated by signal %d" % -rc
exit(error)
elif rc > 0:
print("Please, check your Pandoc installation.")
exit()
error = "Please, check your Pandoc installation."
exit(error)
except OSError, e:
print("Pandoc execution failed: %s" % e)
exit()
error = "Pandoc execution failed: %s" % e
exit(error)
os.remove(html_filename)
@ -302,15 +303,15 @@ def main():
elif args.feed:
input_type = 'feed'
else:
print("You must provide either --wpfile, --dotclear or --feed options")
exit()
error = "You must provide either --wpfile, --dotclear or --feed options"
exit(error)
if not os.path.exists(args.output):
try:
os.mkdir(args.output)
except OSError:
print("Unable to create the output folder: " + args.output)
exit()
error = "Unable to create the output folder: " + args.output
exit(error)
if input_type == 'wordpress':
fields = wp2fields(args.input)

View file

@ -11,11 +11,9 @@ WORDPRESS_XML_SAMPLE = os.path.join(CUR_DIR, 'content', 'wordpressexport.xml')
class TestWordpressXmlImporter(unittest.TestCase):
def setUp(self):
self.posts = wp2fields(WORDPRESS_XML_SAMPLE)
def test_ignore_empty_posts(self):
posts = list(self.posts)
@ -23,7 +21,7 @@ class TestWordpressXmlImporter(unittest.TestCase):
for title, content, fname, date, author, categ, tags, format in posts:
self.assertTrue(title.strip())
@unittest.skipUnless(os.system('pandoc --version') == 0, 'pandoc is not installed')
def test_can_toggle_raw_html_code_parsing(self):
posts = list(self.posts)
@ -34,10 +32,12 @@ class TestWordpressXmlImporter(unittest.TestCase):
rst_files = (r(f) for f in silent_f2p(posts, 'markdown', temp))
self.assertTrue(any('<iframe' in rst for rst in rst_files))
rst_files = (r(f) for f in silent_f2p(posts, 'markdown', temp, strip_raw=True))
rst_files = (r(f) for f in silent_f2p(posts, 'markdown', temp,
strip_raw=True))
self.assertFalse(any('<iframe' in rst for rst in rst_files))
# no effect in rst
rst_files = (r(f) for f in silent_f2p(posts, 'rst', temp))
self.assertFalse(any('<iframe' in rst for rst in rst_files))
rst_files = (r(f) for f in silent_f2p(posts, 'rst', temp, strip_raw=True))
rst_files = (r(f) for f in silent_f2p(posts, 'rst', temp,
strip_raw=True))
self.assertFalse(any('<iframe' in rst for rst in rst_files))