From 1eca1859a9cc41b2cdf890c7b236752aff7811a3 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Sat, 26 May 2012 03:25:46 +0300 Subject: [PATCH 1/2] =?UTF-8?q?Allow=20documentation=20loading=20without=20t?= =?UTF-8?q?idy=20(=C2=B5Tidylib)=20for=20development?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/docs/docload.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/docs/docload.py b/tools/docs/docload.py index c88df7e..e1c0ec4 100755 --- a/tools/docs/docload.py +++ b/tools/docs/docload.py @@ -6,7 +6,11 @@ import sys import os import tarfile import re -import tidy +try: + import tidy +except ImportError, err: + print>>sys.stderr, "WARNING: cannot import tidy: %s" % err + tidy = None from optparse import OptionParser @@ -43,12 +47,16 @@ def load_doc_file(filename, f): title = "" if not quiet: print "--- file: %s (%s) ---" % (filename, title) - s = tidy.parseString(contents.encode('utf-8'), **tidyopts) + if tidy: + s = str(tidy.parseString(contents.encode('utf-8'), **tidyopts)) + else: + s = contents + curs.execute("INSERT INTO docs (file, version, title, content) VALUES (%(f)s, %(v)s, %(t)s, %(c)s)",{ 'f': filename, 'v': ver, 't': title, - 'c': str(s), + 'c': s, }) global pagecount pagecount += 1 -- 1.7.10.2