From 566c1f103ea15f46fe7c0f0ebc94e1a8d407e92d Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Mon, 11 Jul 2011 10:02:03 +1000 Subject: [PATCH] sphinx/pyfs plugins: add error messages for missing imports --- hyde/ext/plugins/sphinx.py | 12 ++++++++---- hyde/ext/publishers/pyfs.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/hyde/ext/plugins/sphinx.py b/hyde/ext/plugins/sphinx.py index 05d0c7f..9eba421 100644 --- a/hyde/ext/plugins/sphinx.py +++ b/hyde/ext/plugins/sphinx.py @@ -20,13 +20,17 @@ from hyde.fs import File, Folder from hyde.model import Expando from hyde.ext.plugins.meta import MetaPlugin as _MetaPlugin -import sphinx -from sphinx.builders.html import JSONHTMLBuilder -from sphinx.util.osutil import SEP - from hyde.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler('hyde.ext.plugins.sphinx') +try: + import sphinx + from sphinx.builders.html import JSONHTMLBuilder + from sphinx.util.osutil import SEP +except ImportError: + logger.error("The sphinx plugin requires sphinx.") + logger.error("`pip install -U sphinx` to get it.") + raise class SphinxPlugin(Plugin): diff --git a/hyde/ext/publishers/pyfs.py b/hyde/ext/publishers/pyfs.py index 9431afb..5a9b4ff 100644 --- a/hyde/ext/publishers/pyfs.py +++ b/hyde/ext/publishers/pyfs.py @@ -21,9 +21,14 @@ from hyde.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler('hyde.ext.publishers.pyfs') -from fs.osfs import OSFS -from fs.path import pathjoin -from fs.opener import fsopendir +try: + from fs.osfs import OSFS + from fs.path import pathjoin + from fs.opener import fsopendir +except ImportError: + logger.error("The PyFS publisher requires PyFilesystem v0.4 or later.") + logger.error("`pip install -U fs` to get it.") + raise