diff options
author | JensDiemer <git@jensdiemer.de> | 2011-08-05 21:30:17 +0200 |
---|---|---|
committer | JensDiemer <git@jensdiemer.de> | 2011-08-05 21:30:17 +0200 |
commit | 0a8da0bb26a97bd9f3d7702716a402b400fa6633 (patch) | |
tree | 92dcf3ae8d5a4e051f7769a323696998269ef08a /creole | |
parent | 4c2430d2cd44f969b57c7297c075b711b4641f2b (diff) | |
download | creole-0a8da0bb26a97bd9f3d7702716a402b400fa6633.tar.gz |
Bugfix if docutils are not installed - API change for rest2html import!
Diffstat (limited to 'creole')
-rw-r--r-- | creole/__init__.py | 8 | ||||
-rw-r--r-- | creole/exceptions.py | 14 | ||||
-rw-r--r-- | creole/rest2html/clean_writer.py | 28 |
3 files changed, 33 insertions, 17 deletions
diff --git a/creole/__init__.py b/creole/__init__.py index d5bd608..9f13a98 100644 --- a/creole/__init__.py +++ b/creole/__init__.py @@ -19,7 +19,7 @@ """ -__version__ = (0, 7, 0) +__version__ = (0, 7, 1) __api__ = (1, 0) # Creole 1.0 spec - http://wikicreole.org/ @@ -33,7 +33,7 @@ from creole.html2creole.emitter import CreoleEmitter from creole.html2rest.emitter import ReStructuredTextEmitter from creole.html2textile.emitter import TextileEmitter from creole.html_parser.parser import HtmlParser -from creole.rest2html.clean_writer import rest2html + # TODO: Add git date to __version__ @@ -106,10 +106,6 @@ def html2rest(html_string, debug=False, parser_kwargs={}, emitter_kwargs={}): >>> html2rest(u'<p>This is <strong>ReStructuredText</strong> <em>markup</em>!</p>') u'This is **ReStructuredText** *markup*!' - - rest2html from creole.rest2html.clean_writer should be also available here: - >>> rest2html(u"A ReSt link to `PyLucid CMS <http://www.pylucid.org>`_ :)") - u'<p>A ReSt link to <a href="http://www.pylucid.org">PyLucid CMS</a> :)</p>\\n' """ document_tree = parse_html(html_string, debug, **parser_kwargs) diff --git a/creole/exceptions.py b/creole/exceptions.py new file mode 100644 index 0000000..105b8f4 --- /dev/null +++ b/creole/exceptions.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# coding: utf-8 + +""" + python-creole exceptions + ~~~~~~~~~~~~~~~~~~~~~~~~ + + :copyleft: 2011 by python-creole team, see AUTHORS for more details. + :license: GNU GPL v3 or above, see LICENSE for more details. +""" + + +class DocutilsImportError(ImportError): + pass diff --git a/creole/rest2html/clean_writer.py b/creole/rest2html/clean_writer.py index 7a07c4c..7ea4c59 100644 --- a/creole/rest2html/clean_writer.py +++ b/creole/rest2html/clean_writer.py @@ -17,22 +17,25 @@ """ -import warnings +#import warnings +import sys +from creole.exceptions import DocutilsImportError try: + import docutils from docutils.core import publish_parts + from docutils.writers import html4css1 except ImportError: - REST_INSTALLED = False - warnings.warn( - "Markup error: 'Python Documentation Utilities' isn't installed. Can't use reStructuredText." - " Download: http://pypi.python.org/pypi/docutils" - ) -else: - REST_INSTALLED = True - - -from docutils.writers import html4css1 + etype, evalue, etb = sys.exc_info() + msg = ( + "%s - You can't use rest2html!" + " Please install: http://pypi.python.org/pypi/docutils" + ) % evalue + evalue = etype(msg) +# evalue.docutils = False # + raise DocutilsImportError, evalue, etb +# raise etype, evalue, etb DEBUG = False @@ -164,6 +167,9 @@ def rest2html(content): >>> rest2html(u"- bullet list") u'<ul>\\n<li>bullet list</li>\\n</ul>\\n' + + >>> rest2html(u"A ReSt link to `PyLucid CMS <http://www.pylucid.org>`_ :)") + u'<p>A ReSt link to <a href="http://www.pylucid.org">PyLucid CMS</a> :)</p>\\n' """ parts = publish_parts( source=content, |